|
@@ -1,5 +1,6 @@
|
|
|
package com.xy.service;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -22,6 +23,7 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static com.xy.utils.Beans.copy;
|
|
@@ -69,7 +71,23 @@ public class SysDictLogServiceImpl extends ServiceImpl<SysDictLogMapper, SysDict
|
|
|
sysDictLog.setId(null);
|
|
|
sysDictLog.setIsSync(false);
|
|
|
sysDictLog.setOperateType(operateType.getIntCode());
|
|
|
- this.save(sysDictLog);
|
|
|
+ if (EnumSysDictOperateType.UPDATE.getIntCode() == operateType.getIntCode()) {
|
|
|
+ String code = sysDictLog.getCode();
|
|
|
+ String paterCode = sysDictLog.getPaterCode();
|
|
|
+ //更新只保存最后一条
|
|
|
+ LambdaQueryWrapper<SysDictLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(StrUtil.isNotEmpty(code), SysDictLog::getCode, code);
|
|
|
+ lambdaQueryWrapper.eq(StrUtil.isNotEmpty(paterCode), SysDictLog::getPaterCode, paterCode);
|
|
|
+ lambdaQueryWrapper.eq(SysDictLog::getOperateType, EnumSysDictOperateType.UPDATE.getIntCode());
|
|
|
+ lambdaQueryWrapper.orderByDesc(SysDictLog::getCreateTime);
|
|
|
+ List<SysDictLog> sysDictLogs = this.list(lambdaQueryWrapper);
|
|
|
+ if (Emptys.check(sysDictLogs)) {
|
|
|
+ SysDictLog log = sysDictLogs.get(0);
|
|
|
+ sysDictLog.setId(log.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sysDictLog.setCreateTime(LocalDateTime.now());
|
|
|
+ saveOrUpdate(sysDictLog);
|
|
|
return true;
|
|
|
}
|
|
|
|