From bb204fc3b7c5ddbcb80408463153ba29422cc183 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 27 May 2021 21:13:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=A4=E5=A4=84=E5=AD=98?= =?UTF-8?q?=E5=9C=A8SQL=E6=B3=A8=E5=85=A5=E6=BC=8F=E6=B4=9E=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/datascope/aspect/DataScopeAspect.java | 14 ++++++++++++++ .../main/resources/mapper/system/SysDeptMapper.xml | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java b/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java index 72aafcdd..453c79c8 100644 --- a/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java +++ b/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java @@ -68,6 +68,7 @@ public class DataScopeAspect @Before("dataScopePointCut()") public void doBefore(JoinPoint point) throws Throwable { + clearDataScope(point); handleDataScope(point); } @@ -169,4 +170,17 @@ public class DataScopeAspect } return null; } + + /** + * 拼接权限sql前先清空params.dataScope参数防止注入 + */ + private void clearDataScope(final JoinPoint joinPoint) + { + Object params = joinPoint.getArgs()[0]; + if (StringUtils.isNotNull(params) && params instanceof BaseEntity) + { + BaseEntity baseEntity = (BaseEntity) params; + baseEntity.getParams().put(DATA_SCOPE, ""); + } + } } diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index f8cdf67c..17fecaa5 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -147,7 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update_by = #{updateBy}, update_time = sysdate() - where dept_id in (${ancestors}) + where find_in_set(#{deptId}, ancestors)