From 9caa82674793eb3ce6b9cfc0dd20d931bcd25e0c Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 周二, 28 5月 2024 16:18:54 +0800
Subject: [PATCH] 兴趣点查询加入自定义权限修改提交
---
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml | 16 ++++++++++++++++
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java | 4 ++++
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 15 +++++++++++++++
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java | 5 +++++
ard-work/src/main/java/com/ruoyi/alarmpoints/well/controller/ArdAlarmpointsWellController.java | 10 ++++++----
5 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/controller/ArdAlarmpointsWellController.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/controller/ArdAlarmpointsWellController.java
index d8ec90c..523ac98 100644
--- a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/controller/ArdAlarmpointsWellController.java
+++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/controller/ArdAlarmpointsWellController.java
@@ -193,11 +193,12 @@
@PostMapping("/wellList")
@ApiOperation("查询权限下所有兴趣点")
public Results wellList() {
- String usersId = SecurityUtils.getUserId();
+ /*String usersId = SecurityUtils.getUserId();
//根据userId查询部门Id
SysUser sysUser = sysUserService.selectUserById(usersId);
//根据当前deptId或者当前及所属下级的所有deptId
- List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
+ List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());*/
+ List<Long> deptList = sysDeptService.selectDeptIdBySubAndUserId(SecurityUtils.getDeptId(),SecurityUtils.getUserId());
//根据deptId获取对应兴趣点数据
List<ArdAlarmpointsWell> list = ardAlarmpointsWellService.wellList(deptList);
return Results.succeed(list);
@@ -206,11 +207,12 @@
@PostMapping("/conditionList")
@ApiOperation("查看部门下筛选条件的兴趣点")
public Results conditionList(ArdAlarmpointsWellParam ardAlarmpointsWellParam) {
- String usersId = SecurityUtils.getUserId();
+ /*String usersId = SecurityUtils.getUserId();
//根据userId查询部门Id
SysUser sysUser = sysUserService.selectUserById(usersId);
//根据当前deptId或者当前及所属下级的所有deptId
- List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
+ List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());*/
+ List<Long> deptList = sysDeptService.selectDeptIdBySubAndUserId(SecurityUtils.getDeptId(),SecurityUtils.getUserId());
ardAlarmpointsWellParam.setDeptList(deptList);
//根据deptId获取对应兴趣点数据
return Results.succeed(ardAlarmpointsWellService.conditionList(ardAlarmpointsWellParam));
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
index 4f436ee..f918968 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
@@ -126,4 +126,8 @@
public int deleteDeptById(Long deptId);
public List<Long> getChildrenDeptIdList(@Param("deptIdList")List<Long> deptIdList);
+
+ public List<Long> selectDeptIdBySub(Long deptId);
+
+ public List<Long> selectRoleDeptIdByUsersId(String usersId);
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java
index 47cf6f0..5234894 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java
@@ -151,4 +151,9 @@
* 人员部门结构树形
*/
List<DeptUserTree> deptUserTree(List<DeptUserTree> depts);
+
+ /**
+ * 查询自身及下属和自定义权限主键
+ * */
+ List<Long> selectDeptIdBySubAndUserId(Long deptId,String usersId);
}
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 56ad9ae..8ddf882 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
@@ -450,6 +450,21 @@
return returnList;
}
+ @Override
+ public List<Long> selectDeptIdBySubAndUserId(Long deptId, String usersId) {
+ List<Long> deptIdList = new ArrayList();
+ //本级及下属部门
+ List<Long> ownAndSubDeptIdList = deptMapper.selectDeptIdBySub(deptId);
+ //自定义
+ List<Long> roleDeptIdList = deptMapper.selectRoleDeptIdByUsersId(usersId);
+ //去重
+ Set<Long> deptIdSet = new HashSet();
+ deptIdSet.addAll(ownAndSubDeptIdList);
+ deptIdSet.addAll(roleDeptIdList);
+ deptIdList.addAll(deptIdSet);
+ return deptIdList;
+ }
+
private void recursionFnDeptUserTree(List<DeptUserTree> list, DeptUserTree t)
{
// 得到子节点列表
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
index 0ade36d..13e09aa 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -165,4 +165,20 @@
#{deptId}
</foreach>
</select>
+
+ <select id="selectDeptIdBySub" resultType="java.lang.Long" parameterType="java.lang.Long">
+ with recursive rsd as (
+ select sd.dept_id from sys_dept sd where sd.dept_id = #{deptId}
+ union
+ select csd.dept_id from sys_dept csd inner join rsd on rsd.dept_id = csd.parent_id
+ )
+ select dept_id from rsd
+ </select>
+
+ <select id="selectRoleDeptIdByUsersId" resultType="java.lang.Long" parameterType="java.lang.String">
+ select srd.dept_id from sys_user su
+ inner join sys_user_role sur on su.user_id = sur.user_id
+ inner join sys_role_dept srd on sur.role_id = srd.role_id
+ where su.user_id = #{usersId}
+ </select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3