mirror of
https://gitee.com/xiaonuobase/snowy.git
synced 2026-03-22 10:47:16 +08:00
【升级】彻底优化登录逻辑、大数据量下的机构以及in拆分
This commit is contained in:
@@ -267,5 +267,9 @@ public abstract class SaBaseLoginUser {
|
||||
/** 数据范围 */
|
||||
@Schema(description = "数据范围")
|
||||
private List<String> dataScope;
|
||||
|
||||
/** 是否全部数据范围(SCOPE_ALL),为true时dataScope为空,表示不需要过滤 */
|
||||
@Schema(description = "是否全部数据范围", hidden = true)
|
||||
private boolean scopeAll;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,17 +39,25 @@ public class StpLoginUserUtil {
|
||||
|
||||
/**
|
||||
* 获取当前B端登录用户的当前请求接口的数据范围
|
||||
* 返回null表示SCOPE_ALL(全部数据权限,无需过滤)
|
||||
* 返回空列表表示无数据权限(需限制)
|
||||
* 返回非空列表表示按机构ID过滤
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/7/8 10:41
|
||||
**/
|
||||
public static List<String> getLoginUserDataScope() {
|
||||
List<String> resultList = CollectionUtil.newArrayList();
|
||||
getLoginUser().getDataScopeList().forEach(dataScope -> {
|
||||
if(dataScope.getApiUrl().equals(CommonServletUtil.getRequest().getServletPath())) {
|
||||
String servletPath = CommonServletUtil.getRequest().getServletPath();
|
||||
for (SaBaseLoginUser.DataScope dataScope : getLoginUser().getDataScopeList()) {
|
||||
if (dataScope.getApiUrl().equals(servletPath)) {
|
||||
if (dataScope.isScopeAll()) {
|
||||
// SCOPE_ALL:返回null表示全部数据权限,无需过滤
|
||||
return null;
|
||||
}
|
||||
resultList.addAll(dataScope.getDataScope());
|
||||
}
|
||||
});
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user