mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
使用Parenthesis为原有表达式添加括号
This commit is contained in:
parent
ebf4ac1d5a
commit
5cc3e6510b
@ -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.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule;
|
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.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
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 com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.jsqlparser.expression.Alias;
|
import net.sf.jsqlparser.expression.*;
|
||||||
import net.sf.jsqlparser.expression.Expression;
|
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
|
||||||
import net.sf.jsqlparser.expression.LongValue;
|
|
||||||
import net.sf.jsqlparser.expression.NullValue;
|
|
||||||
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
|
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
|
||||||
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
|
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
|
||||||
import net.sf.jsqlparser.expression.operators.relational.InExpression;
|
import net.sf.jsqlparser.expression.operators.relational.InExpression;
|
||||||
@ -144,7 +141,7 @@ public class DeptDataPermissionRule implements DataPermissionRule {
|
|||||||
return deptExpression;
|
return deptExpression;
|
||||||
}
|
}
|
||||||
// 目前,如果有指定部门 + 可查看自己,采用 OR 条件。即,WHERE (dept_id IN ? OR user_id = ?)
|
// 目前,如果有指定部门 + 可查看自己,采用 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<Long> deptIds) {
|
private Expression buildDeptExpression(String tableName, Alias tableAlias, Set<Long> deptIds) {
|
||||||
|
@ -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() + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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() + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user