From 9ebaf936c13f7654dc5d58962872b7b4cd054a07 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: Sun, 8 Jan 2023 08:07:48 +0000 Subject: [PATCH] =?UTF-8?q?reset=20=E5=9B=9E=E6=BB=9A=20=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 疯狂的狮子Li <15040126243@163.com> --- .../java/com/ruoyi/common/helper/LoginHelper.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/helper/LoginHelper.java b/ruoyi-common/src/main/java/com/ruoyi/common/helper/LoginHelper.java index 1cef0278..05e370b5 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/helper/LoginHelper.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/helper/LoginHelper.java @@ -81,12 +81,18 @@ public class LoginHelper { LoginUser loginUser = getLoginUser(); if (ObjectUtil.isNull(loginUser)) { String loginId = StpUtil.getLoginIdAsString(); - String[] strs = StringUtils.split(loginId, JOIN_CODE); - if (!ArrayUtil.containsAny(strs, UserType.values())) { + String userId = null; + for (UserType value : UserType.values()) { + if (StringUtils.contains(loginId, value.getUserType())) { + String[] strs = StringUtils.split(loginId, JOIN_CODE); + // 用户id在总是在最后 + userId = strs[strs.length - 1]; + } + } + if (StringUtils.isBlank(userId)) { throw new UtilException("登录用户: LoginId异常 => " + loginId); } - // 用户id在总是在最后 - return Long.parseLong(strs[strs.length - 1]); + return Long.parseLong(userId); } return loginUser.getUserId(); }