From 5c7e8c538146049e63eff0a19be3c87511794a3d Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期四, 27 六月 2024 14:49:59 +0800 Subject: [PATCH] !553 优化获取用户账户 Merge pull request !553 from AprilWind/dev --- ruoyi-common/ruoyi-common-satoken/src/main/java/org/dromara/common/satoken/utils/LoginHelper.java | 34 ++++++++++++++++++++++++---------- 1 files changed, 24 insertions(+), 10 deletions(-) diff --git a/ruoyi-common/ruoyi-common-satoken/src/main/java/org/dromara/common/satoken/utils/LoginHelper.java b/ruoyi-common/ruoyi-common-satoken/src/main/java/org/dromara/common/satoken/utils/LoginHelper.java index 21acfb1..99f6afc 100644 --- a/ruoyi-common/ruoyi-common-satoken/src/main/java/org/dromara/common/satoken/utils/LoginHelper.java +++ b/ruoyi-common/ruoyi-common-satoken/src/main/java/org/dromara/common/satoken/utils/LoginHelper.java @@ -35,6 +35,7 @@ public static final String USER_NAME_KEY = "userName"; public static final String DEPT_KEY = "deptId"; public static final String DEPT_NAME_KEY = "deptName"; + public static final String DEPT_CATEGORY_KEY = "deptCategory"; public static final String CLIENT_KEY = "clientid"; /** @@ -52,10 +53,9 @@ .setExtra(USER_NAME_KEY, loginUser.getUsername()) .setExtra(DEPT_KEY, loginUser.getDeptId()) .setExtra(DEPT_NAME_KEY, loginUser.getDeptName()) + .setExtra(DEPT_CATEGORY_KEY, loginUser.getDeptCategory()) ); - SaSession tokenSession = StpUtil.getTokenSession(); - tokenSession.updateTimeout(model.getTimeout()); - tokenSession.set(LOGIN_USER_KEY, loginUser); + StpUtil.getTokenSession().set(LOGIN_USER_KEY, loginUser); } /** @@ -88,6 +88,13 @@ } /** + * 鑾峰彇鐢ㄦ埛璐︽埛 + */ + public static String getUsername() { + return Convert.toStr(getExtra(USER_NAME_KEY)); + } + + /** * 鑾峰彇绉熸埛ID */ public static String getTenantId() { @@ -102,6 +109,20 @@ } /** + * 鑾峰彇閮ㄩ棬鍚� + */ + public static String getDeptName() { + return Convert.toStr(getExtra(DEPT_NAME_KEY)); + } + + /** + * 鑾峰彇閮ㄩ棬绫诲埆缂栫爜 + */ + public static String getDeptCategory() { + return Convert.toStr(getExtra(DEPT_CATEGORY_KEY)); + } + + /** * 鑾峰彇褰撳墠 Token 鐨勬墿灞曚俊鎭� * * @param key 閿�� @@ -113,13 +134,6 @@ } catch (Exception e) { return null; } - } - - /** - * 鑾峰彇鐢ㄦ埛璐︽埛 - */ - public static String getUsername() { - return getLoginUser().getUsername(); } /** -- Gitblit v1.9.3