From 9d6b0b35a33a6d6abe56bb1b92135df01c5b4567 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期一, 19 十二月 2022 14:30:01 +0800
Subject: [PATCH] update redisson 3.18.0 => 3.19.0
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 39 ++++++++++++++++++++++++++++++---------
1 files changed, 30 insertions(+), 9 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..00b4024 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
@@ -11,10 +11,10 @@
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.helper.DataBaseHelper;
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 +22,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -58,6 +59,18 @@
}
/**
+ * 鏌ヨ閮ㄩ棬鏍戠粨鏋勪俊鎭�
+ *
+ * @param dept 閮ㄩ棬淇℃伅
+ * @return 閮ㄩ棬鏍戜俊鎭泦鍚�
+ */
+ @Override
+ public List<Tree<Long>> selectDeptTreeList(SysDept dept) {
+ List<SysDept> depts = this.selectDeptList(dept);
+ return buildDeptTreeSelect(depts);
+ }
+
+ /**
* 鏋勫缓鍓嶇鎵�闇�瑕佷笅鎷夋爲缁撴瀯
*
* @param depts 閮ㄩ棬鍒楄〃
@@ -84,7 +97,7 @@
@Override
public List<Long> selectDeptListByRoleId(Long roleId) {
SysRole role = roleMapper.selectById(roleId);
- return baseMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
+ return baseMapper.selectDeptListByRoleId(roleId, role.getDeptCheckStrictly());
}
/**
@@ -95,7 +108,11 @@
*/
@Override
public SysDept selectDeptById(Long deptId) {
- return baseMapper.selectById(deptId);
+ SysDept dept = baseMapper.selectById(deptId);
+ SysDept parentDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>()
+ .select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
+ dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null);
+ return dept;
}
/**
@@ -108,7 +125,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(DataBaseHelper.findInSet(deptId, "ancestors")));
}
/**
@@ -163,7 +180,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 +251,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(DataBaseHelper.findInSet(deptId, "ancestors")));
+ 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