fix 修复 优化dubbo调用跟satoken无关的场景会报错无上下文问题

This commit is contained in:
疯狂的狮子Li
2025-06-03 16:11:30 +08:00
parent faa9be7e4e
commit 6d7fb33ae0
4 changed files with 75 additions and 12 deletions

View File

@@ -87,11 +87,14 @@ public class DataPermissionHelper {
* @throws NullPointerException 如果数据权限上下文类型异常则抛出NullPointerException
*/
public static Map<String, Object> getContext() {
SaStorage saStorage = SaHolder.getStorage();
Object attribute = saStorage.get(DATA_PERMISSION_KEY);
if (ObjectUtil.isNull(attribute)) {
saStorage.set(DATA_PERMISSION_KEY, new HashMap<>());
Object attribute = new HashMap<>();
if (SaHolder.getContext().isValid()) {
SaStorage saStorage = SaHolder.getStorage();
attribute = saStorage.get(DATA_PERMISSION_KEY);
if (ObjectUtil.isNull(attribute)) {
saStorage.set(DATA_PERMISSION_KEY, new HashMap<>());
attribute = saStorage.get(DATA_PERMISSION_KEY);
}
}
if (attribute instanceof Map map) {
return map;