update 还原数据权限修改

This commit is contained in:
疯狂的狮子li
2021-05-29 19:49:22 +08:00
parent fab58a4f77
commit 76aa006db5
6 changed files with 24 additions and 24 deletions

View File

@ -3,6 +3,7 @@ package com.ruoyi.framework.aspectj;
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 @@ public class DataScopeAspect
if (StrUtil.isNotBlank(sqlString.toString()))
{
putDataScope(joinPoint, sqlString.substring(4));
putDataScope(joinPoint, "AND (" + sqlString.substring(4) + ")");
}
}
@ -181,12 +182,17 @@ public class DataScopeAspect
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) {
// 方法未找到 不处理
}
}
}
}

View File

@ -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>

View File

@ -58,9 +58,7 @@
and date_format(r.create_time,'%y%m%d') &lt;= 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') &lt;= 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>

View File

@ -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">