From d64abaaed31db05bdd6a67267464480bcde68136 Mon Sep 17 00:00:00 2001 From: keke <994305335@qq.com> Date: Mon, 14 Jul 2025 23:39:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=9C=B0=E5=9D=80'/system/role/authUser/selectAll',=E5=8F=91?= =?UTF-8?q?=E7=94=9F=E6=9C=AA=E7=9F=A5=E5=BC=82=E5=B8=B8:cn.dev33.satoken.?= =?UTF-8?q?exception.NotWebContextException:=20=E9=9D=9EWeb=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E6=96=87=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96Request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/ruoyi/system/service/impl/SysRoleServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ruoyi-modules-api/ruoyi-system-api/src/main/java/org/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-modules-api/ruoyi-system-api/src/main/java/org/ruoyi/system/service/impl/SysRoleServiceImpl.java index b3b24f41..16d329d7 100644 --- a/ruoyi-modules-api/ruoyi-system-api/src/main/java/org/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-modules-api/ruoyi-system-api/src/main/java/org/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -439,6 +439,10 @@ public class SysRoleServiceImpl implements ISysRoleService { if (CollUtil.isEmpty(keys)) { return; } + // 修复:请求地址'/system/role/authUser/selectAll',发生未知异常:cn.dev33.satoken.exception.NotWebContextException: 非Web上下文无法获取Request + // 原因:LoginHelper.getLoginUser(); 由于是并行的方式,上下文出现不一致的情况 + // 解决:只需要把用户信息拿到外面来即可 + LoginUser loginUser = LoginHelper.getLoginUser(); // 角色关联的在线用户量过大会导致redis阻塞卡顿 谨慎操作 keys.forEach(key -> { String token = StringUtils.substringAfterLast(key, ":"); @@ -447,7 +451,6 @@ public class SysRoleServiceImpl implements ISysRoleService { return; } // LoginUser loginUser = LoginHelper.getLoginUser(token); - LoginUser loginUser = LoginHelper.getLoginUser(); if (loginUser.getRoles().stream().anyMatch(r -> r.getRoleId().equals(roleId))) { try { StpUtil.logoutByTokenValue(token);