zhangnaisong
2024-05-28 9caa82674793eb3ce6b9cfc0dd20d931bcd25e0c
兴趣点查询加入自定义权限修改提交
已修改5个文件
50 ■■■■■ 文件已修改
ard-work/src/main/java/com/ruoyi/alarmpoints/well/controller/ArdAlarmpointsWellController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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));
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);
}
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);
}
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)
    {
        // 得到子节点列表
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>