From 28b9fbb4d270855e8d6fdbbbbc584e8e08f7abde Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 19 Jul 2022 15:55:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=9A=E4=B8=AA=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E8=A7=92=E8=89=B2=E6=95=B0=E6=8D=AE=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=9D=83=E9=99=90SQL=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/framework/aspectj/DataScopeAspect.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 ff84bcd..5b0215c 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 @@ -1,5 +1,7 @@ package com.ruoyi.framework.aspectj; +import java.util.ArrayList; +import java.util.List; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; @@ -79,15 +81,21 @@ public class DataScopeAspect * * @param joinPoint 切点 * @param user 用户 - * @param userAlias 别名 + * @param deptAlias 部门别名 + * @param userAlias 用户别名 */ public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) { StringBuilder sqlString = new StringBuilder(); + List conditions = new ArrayList(); for (SysRole role : user.getRoles()) { String dataScope = role.getDataScope(); + if (conditions.contains(dataScope)) + { + continue; + } if (DATA_SCOPE_ALL.equals(dataScope)) { sqlString = new StringBuilder(); @@ -121,6 +129,7 @@ public class DataScopeAspect sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias)); } } + conditions.add(dataScope); } if (StringUtils.isNotBlank(sqlString.toString()))