【升级】彻底优化登录逻辑、大数据量下的机构以及in拆分

This commit is contained in:
俞宝山
2026-02-12 21:11:53 +08:00
parent 6e1a071a73
commit 8dcf6075ff
26 changed files with 1090 additions and 284 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}