From 393a808039bdebc134a2694d72f52f9fe913c6ba Mon Sep 17 00:00:00 2001 From: Tigger <4772787+Jonny-space@user.noreply.gitee.com> Date: Sat, 21 May 2022 07:14:34 +0000 Subject: [PATCH] =?UTF-8?q?DataPermissionHelper.getContext()=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/helper/DataPermissionHelper.java | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/ruoyi-common/ruoyi-common-mybatis/src/main/java/com/ruoyi/common/mybatis/helper/DataPermissionHelper.java b/ruoyi-common/ruoyi-common-mybatis/src/main/java/com/ruoyi/common/mybatis/helper/DataPermissionHelper.java index 38b30895..91ad3272 100644 --- a/ruoyi-common/ruoyi-common-mybatis/src/main/java/com/ruoyi/common/mybatis/helper/DataPermissionHelper.java +++ b/ruoyi-common/ruoyi-common-mybatis/src/main/java/com/ruoyi/common/mybatis/helper/DataPermissionHelper.java @@ -1,13 +1,11 @@ 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 com.ruoyi.common.core.utils.ServletUtils; import lombok.AccessLevel; 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.Map; @@ -35,21 +33,15 @@ public class DataPermissionHelper { } public static Map getContext() { - HttpServletRequest request = ServletUtils.getRequest(); - Object attribute; - if (request != null) { - attribute = request.getAttribute(DATA_PERMISSION_KEY); - if (ObjectUtil.isNull(attribute)) { - request.setAttribute(DATA_PERMISSION_KEY, new HashMap<>()); - 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); - } + /* + *借用satoken的SaStorage存储数据权限标识 + * + */ + SaStorage saStorage = SaHolder.getStorage(); + Object 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) { return (Map) attribute;