From 9caa82674793eb3ce6b9cfc0dd20d931bcd25e0c Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期二, 28 五月 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("鏌ヨ鏉冮檺涓嬫墍鏈夊叴瓒g偣")
public Results wellList() {
- String usersId = SecurityUtils.getUserId();
+ /*String usersId = SecurityUtils.getUserId();
//鏍规嵁userId鏌ヨ閮ㄩ棬Id
SysUser sysUser = sysUserService.selectUserById(usersId);
//鏍规嵁褰撳墠deptId鎴栬�呭綋鍓嶅強鎵�灞炰笅绾х殑鎵�鏈塪eptId
- 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鎴栬�呭綋鍓嶅強鎵�灞炰笅绾х殑鎵�鏈塪eptId
- 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