Commit b04d17c5 authored by 332784038@qq.com's avatar 332784038@qq.com

bugfix: 汇率修改日期补齐

parent 5064e315
......@@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Optional;
......@@ -65,7 +66,12 @@ public class CurrencyRateServiceImpl implements CurrencyRateService {
throw exception(CURRENCY_RATE_EXISTS);
}
mapper.insert(CurrencyRateConvert.INSTANCE.from(req));
CurrencyRateDO entity = CurrencyRateConvert.INSTANCE.from(req);
Date now = new Date();
entity.setCreateTime(now);
entity.setUpdateTime(now);
mapper.insert(entity);
}
@Override
......@@ -90,6 +96,7 @@ public class CurrencyRateServiceImpl implements CurrencyRateService {
public void update(long id, CurrencyRateUpdateReqVO req) {
rate(req.getSourceAmount(), req.getTargetAmount()); // check rate
Date now = new Date();
CurrencyRateLogDO change = new CurrencyRateLogDO();
CurrencyRateDO saved = Optional.ofNullable(mapper.selectById(id))
.orElseThrow(() -> exception(CURRENCY_RATE_NOT_EXISTS));
......@@ -108,9 +115,11 @@ public class CurrencyRateServiceImpl implements CurrencyRateService {
change.setRateId(id);
change.setRemarks(req.getRemarks());
change.setCreateTime(now);
logMapper.insert(change);
CurrencyRateConvert.INSTANCE.update(saved, req);
saved.setUpdateTime(now);
mapper.updateById(saved);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment