From 21cb53bfcaeb0f4b491d916271928dc1b9b6f433 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 29 Sep 2024 21:01:42 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BE=9D=E8=B5=96=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E3=80=91mybatis-plus=20from=203.5.7=20to=203.5.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-dependencies/pom.xml | 5 ++--- .../core/rule/dept/DeptDataPermissionRule.java | 5 +++-- .../core/db/DataPermissionRuleHandlerTest.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 8b4db9cbcc..c587a2c06b 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -24,8 +24,7 @@ 1.2.23 3.5.16 - 3.5.7 - 3.5.7 + 3.5.8 4.3.1 1.4.13 3.0.6 @@ -184,7 +183,7 @@ com.baomidou mybatis-plus-generator - ${mybatis-plus-generator.version} + ${mybatis-plus.version} com.baomidou diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRule.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRule.java index fcb776a3ef..8703819ff6 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRule.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRule.java @@ -21,6 +21,7 @@ import net.sf.jsqlparser.expression.operators.conditional.OrExpression; import net.sf.jsqlparser.expression.operators.relational.EqualsTo; import net.sf.jsqlparser.expression.operators.relational.ExpressionList; import net.sf.jsqlparser.expression.operators.relational.InExpression; +import net.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList; import java.util.HashMap; import java.util.HashSet; @@ -141,7 +142,7 @@ public class DeptDataPermissionRule implements DataPermissionRule { return deptExpression; } // 目前,如果有指定部门 + 可查看自己,采用 OR 条件。即,WHERE (dept_id IN ? OR user_id = ?) - return new Parenthesis(new OrExpression(deptExpression, userExpression)); + return new ParenthesedExpressionList(new OrExpression(deptExpression, userExpression)); } private Expression buildDeptExpression(String tableName, Alias tableAlias, Set deptIds) { @@ -157,7 +158,7 @@ public class DeptDataPermissionRule implements DataPermissionRule { // 拼接条件 return new InExpression(MyBatisUtils.buildColumn(tableName, tableAlias, columnName), // Parenthesis 的目的,是提供 (1,2,3) 的 () 左右括号 - new Parenthesis(new ExpressionList(CollectionUtils.convertList(deptIds, LongValue::new)))); + new ParenthesedExpressionList(new ExpressionList(CollectionUtils.convertList(deptIds, LongValue::new)))); } private Expression buildUserExpression(String tableName, Alias tableAlias, Boolean self, Long userId) { diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionRuleHandlerTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionRuleHandlerTest.java index 0b4ba791a9..c7a0d085e2 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionRuleHandlerTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionRuleHandlerTest.java @@ -8,10 +8,10 @@ import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionIntercepto import net.sf.jsqlparser.expression.Alias; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.LongValue; -import net.sf.jsqlparser.expression.Parenthesis; import net.sf.jsqlparser.expression.operators.relational.EqualsTo; import net.sf.jsqlparser.expression.operators.relational.ExpressionList; import net.sf.jsqlparser.expression.operators.relational.InExpression; +import net.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList; import net.sf.jsqlparser.schema.Column; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -81,7 +81,7 @@ public class DataPermissionRuleHandlerTest extends BaseMockitoUnitTest { Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); ExpressionList values = new ExpressionList<>(new LongValue(10L), new LongValue(20L)); - return new InExpression(column, new Parenthesis((values))); + return new InExpression(column, new ParenthesedExpressionList((values))); } };