feat:用户、角色、菜单、应用列表增加数据权限
This commit is contained in:
+16
-9
@@ -68,15 +68,22 @@ public class DataScopeInnerInterceptor implements InnerInterceptor {
|
||||
|
||||
@Override
|
||||
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
|
||||
if(CollUtil.isEmpty(dataScopeProperties.getIgnoreSqls())|| !dataScopeProperties.getIgnoreSqls().contains(ms.getId())){
|
||||
PluginUtils.MPBoundSql mpBs = PluginUtils.mpBoundSql(boundSql);
|
||||
String sql = boundSql.getSql();
|
||||
try {
|
||||
Select select = explainQuerySql(sql);
|
||||
reform(select.getSelectBody());
|
||||
mpBs.sql(select.toString());
|
||||
} catch (JSQLParserException e) {
|
||||
throw new RuntimeException(e);
|
||||
//为空时:所有sql都添加权限控制
|
||||
if (CollUtil.isEmpty(dataScopeProperties.getIncludeSqls())
|
||||
//有值时:只有配置的sql添加权限控制
|
||||
|| dataScopeProperties.getIncludeSqls().contains(ms.getId())) {
|
||||
//判断排除的sql
|
||||
if(CollUtil.isEmpty(dataScopeProperties.getIgnoreSqls())
|
||||
|| !dataScopeProperties.getIgnoreSqls().contains(ms.getId())){
|
||||
PluginUtils.MPBoundSql mpBs = PluginUtils.mpBoundSql(boundSql);
|
||||
String sql = boundSql.getSql();
|
||||
try {
|
||||
Select select = explainQuerySql(sql);
|
||||
reform(select.getSelectBody());
|
||||
mpBs.sql(select.toString());
|
||||
} catch (JSQLParserException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -43,11 +43,18 @@ public class DataScopeProperties {
|
||||
* 指定某几个表接受权限控制,仅enabled=true,默认当开启时全部表
|
||||
*/
|
||||
private Set<String> includeTables = Collections.singleton("*");
|
||||
/**
|
||||
* 指定某几条sql执行权限控制,仅enabled=true生效
|
||||
* 1. 为空时:所有sql都添加权限控制
|
||||
* 2. 有值时:只有配置的sql添加权限控制
|
||||
*/
|
||||
private Set<String> includeSqls = Collections.emptySet();
|
||||
|
||||
/**
|
||||
* 指定需要的字段名
|
||||
*/
|
||||
private String creatorIdColumnName;
|
||||
private String creatorIdColumnName = "creator_id";
|
||||
|
||||
public void setIgnoreSqls(Set<String> ignoreSqls) {
|
||||
Set<String> ingoreSet = new HashSet<>();
|
||||
ingoreSet.addAll(INGORE_SQL_ID);
|
||||
|
||||
Reference in New Issue
Block a user