From 7d88a713788f9e0d1a42f8026722df427da4a310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Mon, 23 May 2022 16:43:52 +0800 Subject: [PATCH] =?UTF-8?q?reset=20=E5=9B=9E=E6=BB=9A=E9=94=99=E8=AF=AFpr?= =?UTF-8?q?=20=E5=AF=BC=E8=87=B4dubbo=E8=B0=83=E7=94=A8=E4=BC=A0=E9=80=92?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/helper/DataPermissionHelper.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 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 33cb1b0e..38b30895 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,11 +1,13 @@ 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; @@ -33,11 +35,21 @@ public class DataPermissionHelper { } public static Map getContext() { - 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); + 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); + } } if (attribute instanceof Map) { return (Map) attribute;