From 4e04f5e967b14c6f2881d867438653f968027b47 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期二, 28 十二月 2021 14:32:53 +0800 Subject: [PATCH] remove 移除过期代码 数据权限 --- /dev/null | 142 ----------------------------------------------- ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml | 4 - ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 16 ----- ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml | 8 -- 4 files changed, 0 insertions(+), 170 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java deleted file mode 100644 index f1a4f9f..0000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.ruoyi.common.annotation; - -import java.lang.annotation.*; - -/** - * 鏁版嵁鏉冮檺杩囨护娉ㄨВ - * - * @author ruoyi - * @deprecated 3.6.0 绉婚櫎 {@link com.ruoyi.common.annotation.DataPermission} - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Deprecated -public @interface DataScope { - - /** - * 閮ㄩ棬琛ㄧ殑鍒悕 - */ - String deptAlias() default ""; - - /** - * 鐢ㄦ埛琛ㄧ殑鍒悕 - */ - String userAlias() default ""; - - /** - * 鏄惁杩囨护鐢ㄦ埛鏉冮檺 - */ - boolean isUser() default false; - -} 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 deleted file mode 100644 index 1a0d8e0..0000000 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.ruoyi.framework.aspectj; - -import com.ruoyi.common.annotation.DataScope; -import com.ruoyi.common.core.domain.BaseEntity; -import com.ruoyi.common.core.domain.entity.SysRole; -import com.ruoyi.common.core.domain.entity.SysUser; -import com.ruoyi.common.core.domain.model.LoginUser; -import com.ruoyi.common.core.service.UserService; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.spring.SpringUtils; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.springframework.stereotype.Component; - -/** - * 鏁版嵁杩囨护澶勭悊 - * - * @author Lion Li - * @deprecated 3.6.0 绉婚櫎 {@link com.ruoyi.framework.handler.PlusDataPermissionHandler} - */ -@Aspect -@Component -@Deprecated -public class DataScopeAspect { - - /** - * 鍏ㄩ儴鏁版嵁鏉冮檺 - */ - public static final String DATA_SCOPE_ALL = "1"; - - /** - * 鑷畾鏁版嵁鏉冮檺 - */ - public static final String DATA_SCOPE_CUSTOM = "2"; - - /** - * 閮ㄩ棬鏁版嵁鏉冮檺 - */ - public static final String DATA_SCOPE_DEPT = "3"; - - /** - * 閮ㄩ棬鍙婁互涓嬫暟鎹潈闄� - */ - public static final String DATA_SCOPE_DEPT_AND_CHILD = "4"; - - /** - * 浠呮湰浜烘暟鎹潈闄� - */ - public static final String DATA_SCOPE_SELF = "5"; - - /** - * 鏁版嵁鏉冮檺杩囨护鍏抽敭瀛� - */ - public static final String DATA_SCOPE = "dataScope"; - - @Before("@annotation(controllerDataScope)") - public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable { - clearDataScope(point); - handleDataScope(point, controllerDataScope); - } - - protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope) { - // 鑾峰彇褰撳墠鐨勭敤鎴� - LoginUser loginUser = SecurityUtils.getLoginUser(); - if (StringUtils.isNotNull(loginUser)) { - SysUser currentUser = SpringUtils.getBean(UserService.class).selectUserById(loginUser.getUserId()); - // 濡傛灉鏄秴绾х鐞嗗憳锛屽垯涓嶈繃婊ゆ暟鎹� - if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) { - dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), - controllerDataScope.userAlias(), controllerDataScope.isUser()); - } - } - } - - /** - * 鏁版嵁鑼冨洿杩囨护 - * - * @param joinPoint 鍒囩偣 - * @param user 鐢ㄦ埛 - * @param userAlias 鍒悕 - */ - public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias, boolean isUser) { - StringBuilder sqlString = new StringBuilder(); - - // 灏� "." 鎻愬彇鍑�,涓嶅啓鍒悕涓哄崟琛ㄦ煡璇�,鍐欏埆鍚嶄负澶氳〃鏌ヨ - deptAlias = StringUtils.isNotBlank(deptAlias) ? deptAlias + "." : ""; - userAlias = StringUtils.isNotBlank(userAlias) ? userAlias + "." : ""; - - for (SysRole role : user.getRoles()) { - String dataScope = role.getDataScope(); - if (DATA_SCOPE_ALL.equals(dataScope)) { - sqlString = new StringBuilder(); - break; - } else if (DATA_SCOPE_CUSTOM.equals(dataScope)) { - sqlString.append(StringUtils.format( - " OR {}dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", - deptAlias, role.getRoleId())); - } else if (DATA_SCOPE_DEPT.equals(dataScope)) { - sqlString.append(StringUtils.format(" OR {}dept_id = {} ", - deptAlias, user.getDeptId())); - } else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) { - sqlString.append(StringUtils.format( - " OR {}dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", - deptAlias, user.getDeptId(), user.getDeptId())); - } else if (DATA_SCOPE_SELF.equals(dataScope)) { - if (isUser) { - sqlString.append(StringUtils.format(" OR {}user_id = {} ", - userAlias, user.getUserId())); - } else { - // 鏁版嵁鏉冮檺涓轰粎鏈汉涓旀病鏈塽serAlias鍒悕涓嶆煡璇换浣曟暟鎹� - sqlString.append(" OR 1=0 "); - } - } - } - - if (StringUtils.isNotBlank(sqlString.toString())) { - putDataScope(joinPoint, sqlString.substring(4)); - } - } - - /** - * 鎷兼帴鏉冮檺sql鍓嶅厛娓呯┖params.dataScope鍙傛暟闃叉娉ㄥ叆 - */ - private void clearDataScope(final JoinPoint joinPoint) { - Object params = joinPoint.getArgs()[0]; - if (StringUtils.isNotNull(params)) { - putDataScope(joinPoint, ""); - } - } - - private static void putDataScope(JoinPoint joinPoint, String sql) { - Object params = joinPoint.getArgs()[0]; - if (StringUtils.isNotNull(params)) { - if (params instanceof BaseEntity) { - BaseEntity baseEntity = (BaseEntity) params; - baseEntity.getParams().put(DATA_SCOPE, sql); - } - } - } -} diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index 8e9d1d7..c9b5252 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -42,10 +42,6 @@ <if test="status != null and status != ''"> AND status = #{status} </if> -<!-- <!– 鏁版嵁鑼冨洿杩囨护 –>--> -<!-- <if test="params.dataScope != null and params.dataScope != ''">--> -<!-- AND ( ${params.dataScope} )--> -<!-- </if>--> order by d.parent_id, d.order_num </select> diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index c13bd68..15f94f3 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -60,10 +60,6 @@ <if test="role.params.endTime != null and role.params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� --> and date_format(r.create_time,'%y%m%d') <= date_format(#{role.params.endTime},'%y%m%d') </if> -<!-- <!– 鏁版嵁鑼冨洿杩囨护 –>--> -<!-- <if test="role.params.dataScope != null and role.params.dataScope != ''">--> -<!-- AND ( ${role.params.dataScope} )--> -<!-- </if>--> order by r.role_sort </select> @@ -88,10 +84,6 @@ <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� --> and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') </if> -<!-- <!– 鏁版嵁鑼冨洿杩囨护 –>--> -<!-- <if test="params.dataScope != null and params.dataScope != ''">--> -<!-- AND ( ${params.dataScope} )--> -<!-- </if>--> order by r.role_sort </select> diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index c430cbb..62ee4e1 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -108,10 +108,6 @@ AND (u.dept_id = #{user.deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{user.deptId}, ancestors) )) </if> -<!-- <!– 鏁版嵁鑼冨洿杩囨护 –>--> -<!-- <if test="user.params.dataScope != null and user.params.dataScope != ''">--> -<!-- AND ( ${user.params.dataScope} )--> -<!-- </if>--> </select> <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> @@ -142,10 +138,6 @@ AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) )) </if> -<!-- <!– 鏁版嵁鑼冨洿杩囨护 –>--> -<!-- <if test="params.dataScope != null and params.dataScope != ''">--> -<!-- AND ( ${params.dataScope} )--> -<!-- </if>--> </select> <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult"> @@ -161,10 +153,6 @@ <if test="user.phonenumber != null and user.phonenumber != ''"> AND u.phonenumber like concat('%', #{user.phonenumber}, '%') </if> -<!-- <!– 鏁版嵁鑼冨洿杩囨护 –>--> -<!-- <if test="user.params.dataScope != null and user.params.dataScope != ''">--> -<!-- AND ( ${user.params.dataScope} )--> -<!-- </if>--> </select> <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult"> @@ -181,10 +169,6 @@ <if test="user.phonenumber != null and user.phonenumber != ''"> AND u.phonenumber like concat('%', #{user.phonenumber}, '%') </if> -<!-- <!– 鏁版嵁鑼冨洿杩囨护 –>--> -<!-- <if test="user.params.dataScope != null and user.params.dataScope != ''">--> -<!-- AND ( ${user.params.dataScope} )--> -<!-- </if>--> </select> <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult"> -- Gitblit v1.9.3