|
|
@ -1,11 +1,13 @@
|
|
|
|
package com.ruoyi.common.mybatis.helper;
|
|
|
|
package com.ruoyi.common.mybatis.helper;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.dev33.satoken.context.SaHolder;
|
|
|
|
|
|
|
|
import cn.dev33.satoken.context.model.SaStorage;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.utils.ServletUtils;
|
|
|
|
import lombok.AccessLevel;
|
|
|
|
import lombok.AccessLevel;
|
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
|
|
|
|
import org.apache.dubbo.rpc.RpcContext;
|
|
|
|
|
|
|
|
import org.apache.dubbo.rpc.RpcServiceContext;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
@ -33,11 +35,21 @@ public class DataPermissionHelper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Map<String, Object> getContext() {
|
|
|
|
public static Map<String, Object> getContext() {
|
|
|
|
SaStorage saStorage = SaHolder.getStorage();
|
|
|
|
HttpServletRequest request = ServletUtils.getRequest();
|
|
|
|
Object attribute = saStorage.get(DATA_PERMISSION_KEY);
|
|
|
|
Object attribute;
|
|
|
|
|
|
|
|
if (request != null) {
|
|
|
|
|
|
|
|
attribute = request.getAttribute(DATA_PERMISSION_KEY);
|
|
|
|
if (ObjectUtil.isNull(attribute)) {
|
|
|
|
if (ObjectUtil.isNull(attribute)) {
|
|
|
|
saStorage.set(DATA_PERMISSION_KEY, new HashMap<>());
|
|
|
|
request.setAttribute(DATA_PERMISSION_KEY, new HashMap<>());
|
|
|
|
attribute = saStorage.get(DATA_PERMISSION_KEY);
|
|
|
|
attribute = request.getAttribute(DATA_PERMISSION_KEY);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
RpcServiceContext context = RpcContext.getServiceContext();
|
|
|
|
|
|
|
|
attribute = context.getObjectAttachment(DATA_PERMISSION_KEY);
|
|
|
|
|
|
|
|
if (ObjectUtil.isNull(attribute)) {
|
|
|
|
|
|
|
|
context.setObjectAttachment(DATA_PERMISSION_KEY, new HashMap<>());
|
|
|
|
|
|
|
|
attribute = context.getObjectAttachment(DATA_PERMISSION_KEY);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (attribute instanceof Map) {
|
|
|
|
if (attribute instanceof Map) {
|
|
|
|
return (Map<String, Object>) attribute;
|
|
|
|
return (Map<String, Object>) attribute;
|
|
|
|