update 优化 DataPermissionHelper 上下文存储 使用 SaToken 的请求存储器
This commit is contained in:
parent
73e1d3b046
commit
f546ba85aa
@ -1,11 +1,11 @@
|
||||
package com.ruoyi.common.helper;
|
||||
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.context.model.SaStorage;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -33,11 +33,11 @@ public class DataPermissionHelper {
|
||||
}
|
||||
|
||||
public static Map<String, Object> getContext() {
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
Object attribute = request.getAttribute(DATA_PERMISSION_KEY);
|
||||
SaStorage saStorage = SaHolder.getStorage();
|
||||
Object attribute = saStorage.get(DATA_PERMISSION_KEY);
|
||||
if (ObjectUtil.isNull(attribute)) {
|
||||
request.setAttribute(DATA_PERMISSION_KEY, new HashMap<>());
|
||||
attribute = request.getAttribute(DATA_PERMISSION_KEY);
|
||||
saStorage.set(DATA_PERMISSION_KEY, new HashMap<>());
|
||||
attribute = saStorage.get(DATA_PERMISSION_KEY);
|
||||
}
|
||||
if (attribute instanceof Map) {
|
||||
return (Map<String, Object>) attribute;
|
||||
|
Loading…
x
Reference in New Issue
Block a user