From fcfc5c85c7830044862a40d33e0402727a1ef377 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期六, 29 五月 2021 19:51:08 +0800
Subject: [PATCH] update 还原数据权限修改
---
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml | 4 +---
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 8 ++------
ruoyi-ui/src/views/index.vue | 1 -
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java | 20 +++++++++++++-------
ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml | 8 ++------
README.md | 2 +-
6 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/README.md b/README.md
index 2a58722..4aab643 100644
--- a/README.md
+++ b/README.md
@@ -74,7 +74,7 @@
鍏充簬鏁版嵁鏉冮檺
* 鍙傝�冿紙鐢ㄦ埛锛岃鑹诧紝閮ㄩ棬锛夊垪琛ㄦ帴鍙g敤娉�
-* 浠� bo.getParam().get("dataScope") 鍗冲彲鑾峰彇鏁版嵁鏉冮檺鐢熸垚鐨凷QL
+* 鐩墠浠呮敮鎸� XML 鏂瑰紡浣跨敤(鍚庣画淇敼涓烘敮鎸丮P)
鍏充簬vue涓巄oot鏁村悎閮ㄧ讲
* [鍓嶇闈欐�佽祫婧愬浣曟暣鍚堝埌鍚庣璁块棶](https://doc.ruoyi.vip/ruoyi-vue/other/faq.html#鍓嶇闈欐�佽祫婧愬浣曟暣鍚堝埌鍚庣璁块棶)
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 0a766e5..6eec956 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
@@ -3,6 +3,7 @@
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;
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;
@@ -145,7 +146,7 @@
if (StrUtil.isNotBlank(sqlString.toString()))
{
- putDataScope(joinPoint, sqlString.substring(4));
+ putDataScope(joinPoint, "AND (" + sqlString.substring(4) + ")");
}
}
@@ -181,12 +182,17 @@
Object params = joinPoint.getArgs()[0];
if (Validator.isNotNull(params))
{
- try {
- Method getParams = params.getClass().getDeclaredMethod("getParams", null);
- Map<String, Object> invoke = (Map<String, Object>) getParams.invoke(params, null);
- invoke.put(DATA_SCOPE, sql);
- } catch (Exception e) {
- // 鏂规硶鏈壘鍒� 涓嶅鐞�
+ if(params instanceof BaseEntity) {
+ BaseEntity baseEntity = (BaseEntity) params;
+ baseEntity.getParams().put(DATA_SCOPE, "");
+ } else {
+ try {
+ Method getParams = params.getClass().getDeclaredMethod("getParams", null);
+ Map<String, Object> invoke = (Map<String, Object>) getParams.invoke(params, null);
+ invoke.put(DATA_SCOPE, sql);
+ } catch (Exception e) {
+ // 鏂规硶鏈壘鍒� 涓嶅鐞�
+ }
}
}
}
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
index 21f6854..7db8616 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -40,9 +40,7 @@
AND status = #{status}
</if>
<!-- 鏁版嵁鑼冨洿杩囨护 -->
- <if test="params.dataScope != null and params.dataScope != ''">
- AND ( ${params.dataScope} )
- </if>
+ ${params.dataScope}
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 1a542f8..5440f4f 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
@@ -58,9 +58,7 @@
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>
+ ${role.params.dataScope}
order by r.role_sort
</select>
@@ -83,9 +81,7 @@
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>
+ ${params.dataScope}
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 df59332..741600f 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -106,9 +106,7 @@
ancestors) ))
</if>
<!-- 鏁版嵁鑼冨洿杩囨护 -->
- <if test="user.params.dataScope != null and user.params.dataScope != ''">
- AND ( ${user.params.dataScope} )
- </if>
+ ${user.params.dataScope}
</select>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
@@ -137,9 +135,7 @@
ancestors) ))
</if>
<!-- 鏁版嵁鑼冨洿杩囨护 -->
- <if test="params.dataScope != null and params.dataScope != ''">
- AND ( ${params.dataScope} )
- </if>
+ ${params.dataScope}
</select>
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue
index 8dc5060..91beb84 100644
--- a/ruoyi-ui/src/views/index.vue
+++ b/ruoyi-ui/src/views/index.vue
@@ -83,7 +83,6 @@
<el-collapse-item title="v2.2.1 - 2021-5-29">
<ol>
<li>add 澧炲姞 security 鏉冮檺妗嗘灦 @Async 寮傛娉ㄨВ閰嶇疆</li>
- <li>update 浼樺寲鏁版嵁鏉冮檺sql 瑙e喅MP apply娉ㄥ叆闄勫甫 AND 璇硶闂</li>
<li>update 浼樺寲dataScope鍙傛暟闃叉娉ㄥ叆</li>
<li>update 浼樺寲鍙傛暟&瀛楀吀缂撳瓨鎿嶄綔</li>
<li>update 澧炲姞淇敼鍖呭悕鏂囨。</li>
--
Gitblit v1.9.3