join做数据权限
This commit is contained in:
parent
5c1c4d0e72
commit
8abd1df9b8
@ -1,5 +1,6 @@
|
||||
package com.zhgd.mybatis;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.parser.SqlParserHelper;
|
||||
@ -30,10 +31,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public class DataScopeInterceptor extends JsqlParserSupport implements InnerInterceptor {
|
||||
@ -150,6 +148,14 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
|
||||
} else {
|
||||
processFromItem(fromItem, obj);
|
||||
}
|
||||
|
||||
// 如果还存在关联查询
|
||||
List<Join> joins = plainSelect.getJoins();
|
||||
if (CollUtil.isNotEmpty(joins)) {
|
||||
for (Join join : joins) {
|
||||
processJoin(join,obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void processFromItem(FromItem fromItem, Object obj) {
|
||||
@ -160,4 +166,17 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理关联查询
|
||||
*
|
||||
* @param join 关联查询
|
||||
* @param obj
|
||||
*/
|
||||
protected void processJoin(Join join, Object obj) {
|
||||
FromItem joinTable = join.getRightItem();
|
||||
if (joinTable instanceof SubSelect) {
|
||||
processSelectBody(((SubSelect) joinTable).getSelectBody(),obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user