diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java index 9830ebd1..3b346e8c 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java @@ -78,6 +78,11 @@ public class DictBizServiceImpl extends ServiceImpl impl if (cnt > 0) { throw new ServiceException("当前字典键值已存在!"); } + // 修改顶级字典后同步更新下属字典的编号 + if (Func.isNotEmpty(dict.getId()) && dict.getParentId().longValue() == BladeConstant.TOP_PARENT_ID) { + DictBiz parent = DictBizCache.getById(dict.getId()); + this.update(Wrappers.update().lambda().set(DictBiz::getCode, dict.getCode()).eq(DictBiz::getCode, parent.getCode()).ne(DictBiz::getParentId, BladeConstant.TOP_PARENT_ID)); + } if (Func.isEmpty(dict.getParentId())) { dict.setParentId(BladeConstant.TOP_PARENT_ID); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java index 187aac58..1d6c005e 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java @@ -84,6 +84,11 @@ public class DictServiceImpl extends ServiceImpl implements ID if (cnt > 0) { throw new ServiceException("当前字典键值已存在!"); } + // 修改顶级字典后同步更新下属字典的编号 + if (Func.isNotEmpty(dict.getId()) && dict.getParentId().longValue() == BladeConstant.TOP_PARENT_ID) { + Dict parent = DictCache.getById(dict.getId()); + this.update(Wrappers.update().lambda().set(Dict::getCode, dict.getCode()).eq(Dict::getCode, parent.getCode()).ne(Dict::getParentId, BladeConstant.TOP_PARENT_ID)); + } if (Func.isEmpty(dict.getParentId())) { dict.setParentId(BladeConstant.TOP_PARENT_ID); }