From 601d71355f1ced1f50bc68875234ca0e8e5a9179 Mon Sep 17 00:00:00 2001 From: smallchill Date: Thu, 28 Jan 2021 00:11:20 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BF=AE=E6=94=B9=E9=A1=B6=E7=BA=A7?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=90=8E=E5=90=8C=E6=AD=A5=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=B8=8B=E5=B1=9E=E5=AD=97=E5=85=B8=E7=9A=84=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springblade/system/service/impl/DictBizServiceImpl.java | 5 +++++ .../org/springblade/system/service/impl/DictServiceImpl.java | 5 +++++ 2 files changed, 10 insertions(+) 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); }