From ad80e575bd6bfbb501cd432d7f04e10d9973a825 Mon Sep 17 00:00:00 2001 From: AprilWind <2100166581@qq.com> Date: Fri, 19 Jan 2024 16:58:27 +0800 Subject: [PATCH] =?UTF-8?q?update=20LoginHelper=E8=A1=A5=E5=85=85=E7=BC=BA?= =?UTF-8?q?=E5=B0=91=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/satoken/utils/LoginHelper.java | 52 ++++++++++++++++++- 1 file changed, 50 insertions(+), 2 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 ce224b87..35a06108 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 @@ -29,13 +29,40 @@ import java.util.Set; @NoArgsConstructor(access = AccessLevel.PRIVATE) public class LoginHelper { + /** + * 用户信息 + */ public static final String LOGIN_USER_KEY = "loginUser"; + + /** + * 租户ID + */ public static final String TENANT_KEY = "tenantId"; + + /** + * 用户ID + */ public static final String USER_KEY = "userId"; + + /** + * 用户名 + */ public static final String USER_NAME_KEY = "userName"; + + /** + * 部门ID + */ public static final String DEPT_KEY = "deptId"; + + /** + * 部门名称 + */ public static final String DEPT_NAME_KEY = "deptName"; - public static final String CLIENT_KEY = "clientid"; + + /** + * 客户端ID + */ + public static final String CLIENT_KEY = "clientId"; /** * 登录系统 基于 设备类型 @@ -101,6 +128,12 @@ public class LoginHelper { return Convert.toLong(getExtra(DEPT_KEY)); } + /** + * 获取当前 Token 的扩展信息 + * + * @param key 键值 + * @return 对应的扩展数据 + */ private static Object getExtra(String key) { try { return StpUtil.getExtra(key); @@ -135,12 +168,17 @@ public class LoginHelper { return UserConstants.SUPER_ADMIN_ID.equals(userId); } + /** + * 是否为超级管理员 + * + * @return 结果 + */ public static boolean isSuperAdmin() { return isSuperAdmin(getUserId()); } /** - * 是否为超级管理员 + * 是否为租户管理员 * * @param rolePermission 角色权限标识组 * @return 结果 @@ -149,10 +187,20 @@ public class LoginHelper { return rolePermission.contains(TenantConstants.TENANT_ADMIN_ROLE_KEY); } + /** + * 是否为租户管理员 + * + * @return 结果 + */ public static boolean isTenantAdmin() { return Convert.toBool(isTenantAdmin(getLoginUser().getRolePermission())); } + /** + * 检查当前用户是否已登录 + * + * @return 结果 + */ public static boolean isLogin() { return getLoginUser() != null; }