|
@@ -2,6 +2,7 @@ package com.xy.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.BooleanUtil;
|
|
|
import cn.hutool.core.util.CharsetUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
@@ -107,7 +108,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|
|
String paterCode = syncProd.getPaterCode();
|
|
|
String code = syncProd.getCode();
|
|
|
Integer operateType = syncProd.getOperateType();
|
|
|
- if (SysDictDto.SYNC_PWD.equals(syncProd.getPwd())) {
|
|
|
+ if (!SysDictDto.SYNC_PWD.equals(syncProd.getPwd())) {
|
|
|
throw new CommRuntimeException("非法请求!");
|
|
|
}
|
|
|
try {
|
|
@@ -319,8 +320,25 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|
|
if (sysDictLog == null) {
|
|
|
return R.fail("字典日志不存在");
|
|
|
}
|
|
|
+ Boolean isSync = sysDictLog.getIsSync();
|
|
|
+ if (BooleanUtil.isTrue(isSync)) {
|
|
|
+ return R.fail("已同步,请勿重复操作");
|
|
|
+ }
|
|
|
+ Integer sysDictId = sysDictLog.getSysDictId();
|
|
|
+ SysDict sysDict = getById(sysDictId);
|
|
|
SysDictDto.SyncProd syncProd = BeanUtil.copyProperties(sysDictLog, SysDictDto.SyncProd.class);
|
|
|
- String res = sendPost(SYNC_DICT_URL, JSONUtil.toJsonStr(syncProd));
|
|
|
+ syncProd.setValue(sysDictLog.getValue());
|
|
|
+ if (sysDict != null) {
|
|
|
+ //非删除
|
|
|
+ syncProd.setCssClass(sysDict.getCssClass());
|
|
|
+ syncProd.setListClass(sysDict.getListClass());
|
|
|
+ syncProd.setOrders(sysDict.getOrders());
|
|
|
+ }
|
|
|
+ syncProd.setPwd(SysDictDto.SYNC_PWD);
|
|
|
+
|
|
|
+ String body = JSONUtil.toJsonStr(syncProd);
|
|
|
+ log.info("字典同步数据: {}", body);
|
|
|
+ String res = sendPost(SYNC_DICT_URL, body);
|
|
|
if ("fail".equals(res)) {
|
|
|
return R.fail("同步失败,请稍后重试");
|
|
|
} else {
|
|
@@ -345,7 +363,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|
|
save(sysDict);
|
|
|
//日志
|
|
|
SysDictLog sysDictLog = BeanUtil.copyProperties(sysDict, SysDictLog.class);
|
|
|
- sysDictLogService.handleLog(sysDictLog, EnumSysDictOperateType.ADD);
|
|
|
+ sysDictLogService.handleLog(sysDict, sysDictLog, EnumSysDictOperateType.ADD);
|
|
|
//刷新redis
|
|
|
refuRedis(sysDict);
|
|
|
return R.ok();
|
|
@@ -371,7 +389,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|
|
sysDicts.forEach(sd -> {
|
|
|
sd.setPaterCode(update.getCode());
|
|
|
SysDictLog sysDictLog = BeanUtil.copyProperties(sd, SysDictLog.class);
|
|
|
- sysDictLogService.handleLog(sysDictLog, EnumSysDictOperateType.ADD);
|
|
|
+ sysDictLogService.handleLog(sysDict, sysDictLog, EnumSysDictOperateType.ADD);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -384,7 +402,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|
|
update(new SysDict().setPaterCode(obj.getCode()), new LambdaQueryWrapper<SysDict>().eq(SysDict::getPaterCode, sysDict.getCode()));
|
|
|
//日志
|
|
|
SysDictLog sysDictLog = BeanUtil.copyProperties(sysDict, SysDictLog.class);
|
|
|
- sysDictLogService.handleLog(sysDictLog, EnumSysDictOperateType.UPDATE);
|
|
|
+ sysDictLogService.handleLog(sysDict, sysDictLog, EnumSysDictOperateType.UPDATE);
|
|
|
|
|
|
//刷新redis
|
|
|
refuRedis(obj);
|
|
@@ -403,7 +421,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
list.forEach(sysDict -> {
|
|
|
SysDictLog sysDictLog = BeanUtil.copyProperties(sysDict, SysDictLog.class);
|
|
|
- sysDictLogService.handleLog(sysDictLog, EnumSysDictOperateType.DEL);
|
|
|
+ sysDictLogService.handleLog(sysDict, sysDictLog, EnumSysDictOperateType.DEL);
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -421,7 +439,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|
|
removeBatchByIds(sysDicts);
|
|
|
sysDicts.forEach(sysDict -> {
|
|
|
SysDictLog sysDictLog = BeanUtil.copyProperties(sysDict, SysDictLog.class);
|
|
|
- sysDictLogService.handleLog(sysDictLog, EnumSysDictOperateType.DEL);
|
|
|
+ sysDictLogService.handleLog(sysDict, sysDictLog, EnumSysDictOperateType.DEL);
|
|
|
});
|
|
|
}
|
|
|
|