From 2dd8dc9ef66dbcbe2a900a1a812bbdd852edad8f Mon Sep 17 00:00:00 2001 From: Odboy Date: Tue, 25 Mar 2025 20:54:52 +0800 Subject: [PATCH] =?UTF-8?q?upd:=20=E7=BC=96=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/system/mapper/DeptMapper.java | 19 ++++++------------- .../system/service/impl/DeptServiceImpl.java | 18 +++++++++--------- .../src/main/resources/mapper/DeptMapper.xml | 14 ++++++++++---- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/modules/system/mapper/DeptMapper.java b/cutejava/cutejava-system/src/main/java/cn/odboy/modules/system/mapper/DeptMapper.java index e166637e..c86f3890 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/modules/system/mapper/DeptMapper.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/modules/system/mapper/DeptMapper.java @@ -12,17 +12,10 @@ import java.util.Set; @Mapper public interface DeptMapper extends BaseMapper { - - List selectByPage(@Param("criteria") DeptQueryCriteria criteria); - - List selectByPid(@Param("pid") Long pid); - @Select("select count(*) from sys_dept where pid = #{pid}") - int countByPid(@Param("pid") Long pid); - - List selectByPidIsNull(); - - Set selectByRoleId(@Param("roleId") Long roleId); - - @Select("update sys_dept set sub_count = #{count} where dept_id = #{id}") - void updateSubCntById(@Param("count") Integer count, @Param("id") Long id); + List findDeptListByPage(@Param("criteria") DeptQueryCriteria criteria); + List findDeptListByPid(@Param("pid") Long pid); + int countDeptByPid(@Param("pid") Long pid); + List findDeptListByPidIsNull(); + Set findDeptSetByRoleId(@Param("roleId") Long roleId); + void updateDeptSubCountById(@Param("count") Integer count, @Param("id") Long id); } \ No newline at end of file diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/modules/system/service/impl/DeptServiceImpl.java b/cutejava/cutejava-system/src/main/java/cn/odboy/modules/system/service/impl/DeptServiceImpl.java index cae7aed2..7bda7c1e 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/modules/system/service/impl/DeptServiceImpl.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/modules/system/service/impl/DeptServiceImpl.java @@ -64,7 +64,7 @@ public class DeptServiceImpl extends ServiceImpl implements De } // 数据权限 criteria.setIds(SecurityUtil.getCurrentUserDataScope()); - List list = deptMapper.selectByPage(criteria); + List list = deptMapper.findDeptListByPage(criteria); // 如果为空,就代表为自定义权限或者本级权限,就需要去重,不理解可以注释掉,看查询结果 if (StringUtil.isBlank(dataScopeType)) { return deduplication(list); @@ -85,12 +85,12 @@ public class DeptServiceImpl extends ServiceImpl implements De @Override public List findByPid(long pid) { - return deptMapper.selectByPid(pid); + return deptMapper.findDeptListByPid(pid); } @Override public Set findByRoleId(Long id) { - return deptMapper.selectByRoleId(id); + return deptMapper.findDeptSetByRoleId(id); } @Override @@ -150,7 +150,7 @@ public class DeptServiceImpl extends ServiceImpl implements De public Set getDeleteDepts(List menuList, Set deptSet) { for (Dept dept : menuList) { deptSet.add(dept); - List depts = deptMapper.selectByPid(dept.getId()); + List depts = deptMapper.findDeptListByPid(dept.getId()); if (CollUtil.isNotEmpty(depts)) { getDeleteDepts(depts, deptSet); } @@ -163,7 +163,7 @@ public class DeptServiceImpl extends ServiceImpl implements De List list = new ArrayList<>(); deptList.forEach(dept -> { if (dept != null && dept.getEnabled()) { - List depts = deptMapper.selectByPid(dept.getId()); + List depts = deptMapper.findDeptListByPid(dept.getId()); if (CollUtil.isNotEmpty(depts)) { list.addAll(getDeptChildren(depts)); } @@ -177,10 +177,10 @@ public class DeptServiceImpl extends ServiceImpl implements De @Override public List getSuperior(Dept dept, List depts) { if (dept.getPid() == null) { - depts.addAll(deptMapper.selectByPidIsNull()); + depts.addAll(deptMapper.findDeptListByPidIsNull()); return depts; } - depts.addAll(deptMapper.selectByPid(dept.getPid())); + depts.addAll(deptMapper.findDeptListByPid(dept.getPid())); return getSuperior(findById(dept.getPid()), depts); } @@ -233,8 +233,8 @@ public class DeptServiceImpl extends ServiceImpl implements De private void updateSubCnt(Long deptId) { if (deptId != null) { - int count = deptMapper.countByPid(deptId); - deptMapper.updateSubCntById(count, deptId); + int count = deptMapper.countDeptByPid(deptId); + deptMapper.updateDeptSubCountById(count, deptId); } } diff --git a/cutejava/cutejava-system/src/main/resources/mapper/DeptMapper.xml b/cutejava/cutejava-system/src/main/resources/mapper/DeptMapper.xml index f588239b..a1a5ee32 100644 --- a/cutejava/cutejava-system/src/main/resources/mapper/DeptMapper.xml +++ b/cutejava/cutejava-system/src/main/resources/mapper/DeptMapper.xml @@ -13,8 +13,11 @@ + + update sys_dept set sub_count = #{count} where dept_id = #{id} + - SELECT dept_id, `name`, @@ -54,21 +57,21 @@ ORDER BY dept_sort - select dept_id, name, pid, sub_count, create_time, update_time, create_by, update_by, enabled, dept_sort from sys_dept where pid = #{pid} - select dept_id, name, pid, sub_count, create_time, update_time, create_by, update_by, enabled, dept_sort from sys_dept where pid is null - SELECT d.dept_id AS id, d.NAME, @@ -87,4 +90,7 @@ d.dept_id = rd.dept_id AND rd.role_id = #{roleId} + \ No newline at end of file