From e339298a0b94505a0dd283f7f0d9c0cf0aa51987 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期一, 24 七月 2023 17:29:53 +0800 Subject: [PATCH] 增加用户任务数据过滤 --- ard-work/src/main/resources/mapper/app/ArdAppTaskMapper.xml | 13 ++++--------- ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java | 8 ++++++++ ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java | 2 +- ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml | 4 ---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ard-work/src/main/resources/mapper/app/ArdAppTaskMapper.xml b/ard-work/src/main/resources/mapper/app/ArdAppTaskMapper.xml index b3c7423..6688e65 100644 --- a/ard-work/src/main/resources/mapper/app/ArdAppTaskMapper.xml +++ b/ard-work/src/main/resources/mapper/app/ArdAppTaskMapper.xml @@ -52,8 +52,8 @@ c.name, c.text, c.voice, - c.dept_id, - c.user_id, + d.dept_id, + u.user_id, c.create_by, c.create_time, c.update_by, @@ -69,14 +69,9 @@ <if test="name != null and name != ''">and name like '%'||#{name}||'%'</if> <if test="text != null and text != ''">and text = #{text}</if> <if test="voice != null and voice != ''">and voice = #{voice}</if> - <if test="deptId != null and deptId != 0 "> - and (c.dept_id = #{deptId} OR c.dept_id IN ( SELECT t.dept_id FROM sys_dept t - WHERE cast(#{deptId} as varchar) = any(string_to_array(ancestors,',')) )) - </if> - <if test="userId != null and userId != ''">and user_id = #{userId}</if> + <!-- 鏁版嵁鑼冨洿杩囨护 --> + ${params.dataScope} </where> - <!-- 鏁版嵁鑼冨洿杩囨护 --> - ${params.dataScope} </select> <select id="selectArdAppTaskById" parameterType="String" resultMap="ArdAppTaskSubResult"> diff --git a/ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml b/ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml index 19fdea3..7907744 100644 --- a/ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml +++ b/ard-work/src/main/resources/mapper/device/ArdCamerasMapper.xml @@ -81,10 +81,6 @@ <if test="longitude != null ">and c.longitude = #{longitude}</if> <if test="latitude != null ">and c.latitude = #{latitude}</if> <if test="altitude != null ">and c.altitude = #{altitude}</if> - <if test="userId != null and userId != ''">and c.user_id = #{userId}</if> - <if test="deptId != null ">and (c.dept_id = #{deptId} OR c.dept_id IN ( SELECT t.dept_id FROM sys_dept t - WHERE cast(#{deptId} as varchar) = any(string_to_array(ancestors,',')) )) - </if> <if test="camHeading != null ">and c.cam_heading = #{camHeading}</if> <if test="camPitch != null ">and c.cam_pitch = #{camPitch}</if> <if test="camRoll != null ">and c.cam_roll = #{camRoll}</if> diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java index 151ebb4..4e5bf1e 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java @@ -146,6 +146,14 @@ { return userId != null && userId.equals("1"); } + public boolean isApp() + { + return isApp(this.userId); + } + public boolean isApp(String userId) + { + return userId != null && this.getRoles().stream().anyMatch(sysRole -> sysRole.getRoleKey().contains("appLeader")); + } public Long getDeptId() { diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index 63fa636..c961522 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -70,7 +70,7 @@ { SysUser currentUser = loginUser.getUser(); // 濡傛灉鏄秴绾х鐞嗗憳锛屽垯涓嶈繃婊ゆ暟鎹� - if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) + if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()&& !currentUser.isApp()) { String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), PermissionContextHolder.getContext()); dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), -- Gitblit v1.9.3