| | |
| | | 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; |
| | |
| | | |
| | | // 情况二,即不能查看部门,又不能查看自己,则说明 100% 无权限 |
| | | if (CollUtil.isEmpty(deptDataPermission.getDeptIds()) |
| | | && Boolean.FALSE.equals(deptDataPermission.getSelf())) { |
| | | && Boolean.FALSE.equals(deptDataPermission.getSelf())) { |
| | | return new EqualsTo(null, null); // WHERE null = null,可以保证返回的数据为空 |
| | | } |
| | | |
| | |
| | | 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<Long> deptIds) { |
| | |
| | | } |
| | | // 拼接条件 |
| | | return new InExpression(MyBatisUtils.buildColumn(tableName, tableAlias, columnName), |
| | | // new Parenthesis(new ExpressionList<>(CollectionUtils.convertList(deptIds, LongValue::new)))); |
| | | new ExpressionList(CollectionUtils.convertList(deptIds, LongValue::new))); |
| | | // Parenthesis 的目的,是提供 (1,2,3) 的 () 左右括号 |
| | | new ParenthesedExpressionList(new ExpressionList<LongValue>(CollectionUtils.convertList(deptIds, LongValue::new)))); |
| | | } |
| | | |
| | | private Expression buildUserExpression(String tableName, Alias tableAlias, Boolean self, Long userId) { |
| | |
| | | |
| | | public void addDeptColumn(Class<? extends BaseDO> entityClass, String columnName) { |
| | | String tableName = TableInfoHelper.getTableInfo(entityClass).getTableName(); |
| | | addDeptColumn(tableName, columnName); |
| | | addDeptColumn(tableName, columnName); |
| | | } |
| | | |
| | | public void addDeptColumn(String tableName, String columnName) { |