fix 修复数据权限 仅自己 相关问题

feature/model
疯狂的狮子li 3 years ago
parent 2a8a72a085
commit c5dbd04c9c

@ -23,34 +23,39 @@ public enum DataScopeType {
/**
*
*/
ALL("1", ""),
ALL("1", "", ""),
/**
*
*/
CUSTOM("2", " #{#deptName} IN ( #{@sdss.getRoleCustom( #user.roleId )} ) "),
CUSTOM("2", " #{#deptName} IN ( #{@sdss.getRoleCustom( #user.roleId )} ) ", ""),
/**
*
*/
DEPT("3", " #{#deptName} = #{#user.deptId} "),
DEPT("3", " #{#deptName} = #{#user.deptId} ", ""),
/**
*
*/
DEPT_AND_CHILD("4", " #{#deptName} IN ( #{@sdss.getDeptAndChild( #user.deptId )} )"),
DEPT_AND_CHILD("4", " #{#deptName} IN ( #{@sdss.getDeptAndChild( #user.deptId )} )", ""),
/**
*
*/
SELF("5", " #{#userName?:1} = #{#user.userId} ");
SELF("5", " #{#userName} = #{#user.userId} " , " 1 = 0 ");
private final String code;
/**
* spel
*/
private final String sql;
private final String sqlTemplate;
/**
* sqlTemplate
*/
private final String elseSql;
public static DataScopeType findCode(String code) {
if (StringUtils.isBlank(code)) {

@ -96,13 +96,14 @@ public class PlusDataPermissionHandler {
return "";
}
// 不包含 key 变量 则不处理
if (!StringUtils.contains(type.getSql(), "#" + dataColumn.key())) {
if (!StringUtils.contains(type.getSqlTemplate(), "#" + dataColumn.key())) {
sqlString.append(type.getElseSql());
continue;
}
// 更新或删除需满足所有条件
sqlString.append(isSelect ? " OR " : " AND ");
// 解析sql模板并填充
String sql = parser.parseExpression(type.getSql(), parserContext).getValue(context, String.class);
String sql = parser.parseExpression(type.getSqlTemplate(), parserContext).getValue(context, String.class);
sqlString.append(sql);
}
}

Loading…
Cancel
Save