From 3eb66cb16eff58a8a8ec25664bf15127aa3c3834 Mon Sep 17 00:00:00 2001 From: theo <971366405@qq.com> Date: Fri, 14 Nov 2025 14:51:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor(dept):=E4=BC=98=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E6=9C=8D=E5=8A=A1=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 Collections.EMPTY_LIST 替换为 Collections.emptyList() -优化树路径删除逻辑,使用预定义模式匹配- 提取重复代码为局部变量 --- .../com/youlai/boot/system/service/impl/DeptServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/youlai/boot/system/service/impl/DeptServiceImpl.java b/src/main/java/com/youlai/boot/system/service/impl/DeptServiceImpl.java index 39a60deb..db0ec596 100644 --- a/src/main/java/com/youlai/boot/system/service/impl/DeptServiceImpl.java +++ b/src/main/java/com/youlai/boot/system/service/impl/DeptServiceImpl.java @@ -108,7 +108,7 @@ public class DeptServiceImpl extends ServiceImpl implements De .orderByAsc(Dept::getSort) ); if (CollectionUtil.isEmpty(deptList)) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } Set deptIds = deptList.stream() @@ -238,10 +238,11 @@ public class DeptServiceImpl extends ServiceImpl implements De if (StrUtil.isNotBlank(ids)) { String[] menuIds = ids.split(","); for (String deptId : menuIds) { + String patten = "%," + deptId + ",%"; this.update(new LambdaUpdateWrapper() .eq(Dept::getId, deptId) .or() - .apply("CONCAT (',',tree_path,',') LIKE CONCAT('%,',{0},',%')", deptId) + .apply("CONCAT (',',tree_path,',') LIKE {0}", patten) .set(Dept::getIsDeleted, 1) .set(Dept::getUpdateBy, SecurityUtils.getUserId()) );