From 3ecb28549f1fef0f161be1937b1474b7c3b0224e Mon Sep 17 00:00:00 2001 From: theo <971366405@qq.com> Date: Wed, 10 Sep 2025 10:58:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(dict):=20=E6=B7=BB=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=94=AF=E6=8C=81=E5=B9=B6=E5=9C=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E6=9B=B4=E6=96=B0=E7=9B=B8=E5=85=B3=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/impl/DictServiceImpl.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/youlai/boot/system/service/impl/DictServiceImpl.java b/src/main/java/com/youlai/boot/system/service/impl/DictServiceImpl.java index 256f76bb..8d1f9896 100644 --- a/src/main/java/com/youlai/boot/system/service/impl/DictServiceImpl.java +++ b/src/main/java/com/youlai/boot/system/service/impl/DictServiceImpl.java @@ -108,6 +108,7 @@ public class DictServiceImpl extends ServiceImpl implements Di * @param dictForm 字典表单 */ @Override + @Transactional public boolean updateDict(Long id, DictForm dictForm) { // 获取字典 Dict entity = this.getById(id); @@ -125,7 +126,25 @@ public class DictServiceImpl extends ServiceImpl implements Di // 更新字典 Dict dict = dictConverter.toEntity(dictForm); dict.setId(id); - return this.updateById(dict); + boolean result = this.updateById(dict); + if (result) { + // 更新字典数据 + List dictItemList = dictItemService.list( + new LambdaQueryWrapper() + .eq(DictItem::getDictCode, entity.getDictCode()) + .select(DictItem::getId) + ); + if (!dictItemList.isEmpty()){ + List dictItemIds = dictItemList.stream().map(DictItem::getId).toList(); + DictItem dictItem = new DictItem(); + dictItem.setDictCode(dict.getDictCode()); + dictItemService.update(dictItem, + new LambdaQueryWrapper() + .in(DictItem::getId, dictItemIds) + ); + } + } + return result; } /**