Browse Source

修改顶级字典后同步更新下属字典的编号

test
smallchill 4 years ago
parent
commit
601d71355f
  1. 5
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java
  2. 5
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java

5
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java

@ -78,6 +78,11 @@ public class DictBizServiceImpl extends ServiceImpl<DictBizMapper, DictBiz> impl
if (cnt > 0) { if (cnt > 0) {
throw new ServiceException("当前字典键值已存在!"); throw new ServiceException("当前字典键值已存在!");
} }
// 修改顶级字典后同步更新下属字典的编号
if (Func.isNotEmpty(dict.getId()) && dict.getParentId().longValue() == BladeConstant.TOP_PARENT_ID) {
DictBiz parent = DictBizCache.getById(dict.getId());
this.update(Wrappers.<DictBiz>update().lambda().set(DictBiz::getCode, dict.getCode()).eq(DictBiz::getCode, parent.getCode()).ne(DictBiz::getParentId, BladeConstant.TOP_PARENT_ID));
}
if (Func.isEmpty(dict.getParentId())) { if (Func.isEmpty(dict.getParentId())) {
dict.setParentId(BladeConstant.TOP_PARENT_ID); dict.setParentId(BladeConstant.TOP_PARENT_ID);
} }

5
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java

@ -84,6 +84,11 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
if (cnt > 0) { if (cnt > 0) {
throw new ServiceException("当前字典键值已存在!"); throw new ServiceException("当前字典键值已存在!");
} }
// 修改顶级字典后同步更新下属字典的编号
if (Func.isNotEmpty(dict.getId()) && dict.getParentId().longValue() == BladeConstant.TOP_PARENT_ID) {
Dict parent = DictCache.getById(dict.getId());
this.update(Wrappers.<Dict>update().lambda().set(Dict::getCode, dict.getCode()).eq(Dict::getCode, parent.getCode()).ne(Dict::getParentId, BladeConstant.TOP_PARENT_ID));
}
if (Func.isEmpty(dict.getParentId())) { if (Func.isEmpty(dict.getParentId())) {
dict.setParentId(BladeConstant.TOP_PARENT_ID); dict.setParentId(BladeConstant.TOP_PARENT_ID);
} }

Loading…
Cancel
Save