From 5cc3e6510b0328f6ab9c913df9cb1346add9be7b Mon Sep 17 00:00:00 2001 From: JUNHAO Date: Thu, 24 Aug 2023 14:38:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8Parenthesis=E4=B8=BA=E5=8E=9F?= =?UTF-8?q?=E6=9C=89=E8=A1=A8=E8=BE=BE=E5=BC=8F=E6=B7=BB=E5=8A=A0=E6=8B=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rule/dept/DeptDataPermissionRule.java | 9 +++---- .../framework/expression/AndExpressionX.java | 24 ------------------- .../framework/expression/OrExpressionX.java | 24 ------------------- 3 files changed, 3 insertions(+), 54 deletions(-) delete mode 100644 yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/expression/AndExpressionX.java delete mode 100644 yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/expression/OrExpressionX.java 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 41f03fbe6e..bc54314b4e 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 @@ -7,7 +7,6 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule; -import cn.iocoder.yudao.framework.expression.OrExpressionX; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; import cn.iocoder.yudao.framework.security.core.LoginUser; @@ -17,10 +16,8 @@ import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespD import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.LongValue; -import net.sf.jsqlparser.expression.NullValue; +import net.sf.jsqlparser.expression.*; +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; @@ -144,7 +141,7 @@ public class DeptDataPermissionRule implements DataPermissionRule { return deptExpression; } // 目前,如果有指定部门 + 可查看自己,采用 OR 条件。即,WHERE (dept_id IN ? OR user_id = ?) - return new OrExpressionX(deptExpression, userExpression); + return new Parenthesis(new OrExpression(deptExpression, userExpression)); } private Expression buildDeptExpression(String tableName, Alias tableAlias, Set deptIds) { diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/expression/AndExpressionX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/expression/AndExpressionX.java deleted file mode 100644 index 54198e496b..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/expression/AndExpressionX.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.framework.expression; - -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.operators.conditional.AndExpression; - -/** - * AndExpression 的扩展类(会在原有表达式两端加上括号) - */ -public class AndExpressionX extends AndExpression { - - public AndExpressionX() { - } - - public AndExpressionX(Expression leftExpression, Expression rightExpression) { - this.setLeftExpression(leftExpression); - this.setRightExpression(rightExpression); - } - - @Override - public String toString() { - return "(" + super.toString() + ")"; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/expression/OrExpressionX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/expression/OrExpressionX.java deleted file mode 100644 index 19b4695cfe..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/expression/OrExpressionX.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.framework.expression; - -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.operators.conditional.OrExpression; - -/** - * OrExpression 的扩展类(会在原有表达式两端加上括号) - */ -public class OrExpressionX extends OrExpression { - - public OrExpressionX() { - } - - public OrExpressionX(Expression leftExpression, Expression rightExpression) { - this.setLeftExpression(leftExpression); - this.setRightExpression(rightExpression); - } - - @Override - public String toString() { - return "(" + super.toString() + ")"; - } - -}