From 78d0e67987ae1d8cc350308e8369fe817019290d Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期三, 09 三月 2022 12:11:34 +0800 Subject: [PATCH] update 处理 find_in_set 函数多类型数据库兼容性问题 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 97a2617..3ef5eb8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -14,7 +14,6 @@ import com.ruoyi.common.helper.LoginHelper; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.TreeBuildUtils; -import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.SysUserMapper; @@ -22,6 +21,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -108,7 +108,7 @@ public long selectNormalChildrenDeptById(Long deptId) { return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>() .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL) - .apply("find_in_set({0}, ancestors)", deptId)); + .apply("find_in_set({0}, ancestors) <> 0", deptId)); } /** @@ -163,7 +163,7 @@ if (!LoginHelper.isAdmin()) { SysDept dept = new SysDept(); dept.setDeptId(deptId); - List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); + List<SysDept> depts = this.selectDeptList(dept); if (CollUtil.isEmpty(depts)) { throw new ServiceException("娌℃湁鏉冮檺璁块棶閮ㄩ棬鏁版嵁锛�"); } @@ -234,12 +234,16 @@ */ public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) { List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>() - .apply("find_in_set({0},ancestors)", deptId)); + .apply("find_in_set({0},ancestors) <> 0", deptId)); + List<SysDept> list = new ArrayList<>(); for (SysDept child : children) { - child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); + SysDept dept = new SysDept(); + dept.setDeptId(child.getDeptId()); + dept.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); + list.add(dept); } - if (children.size() > 0) { - baseMapper.updateDeptChildren(children); + if (list.size() > 0) { + baseMapper.updateBatchById(list); } } -- Gitblit v1.9.3