| | |
| | | import cn.dev33.satoken.session.SaSession; |
| | | import cn.dev33.satoken.stp.SaLoginModel; |
| | | import cn.dev33.satoken.stp.StpUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import lombok.AccessLevel; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取用户账户 |
| | | */ |
| | | public static String getUsername() { |
| | | return Convert.toStr(getExtra(USER_NAME_KEY)); |
| | | } |
| | | |
| | | /** |
| | | * 获取租户ID |
| | | */ |
| | | public static String getTenantId() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取用户账户 |
| | | */ |
| | | public static String getUsername() { |
| | | return getLoginUser().getUsername(); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户类型 |
| | | */ |
| | | public static UserType getUserType() { |
| | |
| | | * @return 结果 |
| | | */ |
| | | public static boolean isTenantAdmin(Set<String> rolePermission) { |
| | | if (CollUtil.isEmpty(rolePermission)) { |
| | | return false; |
| | | } |
| | | return rolePermission.contains(TenantConstants.TENANT_ADMIN_ROLE_KEY); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | public static boolean isLogin() { |
| | | return getLoginUser() != null; |
| | | try { |
| | | return getLoginUser() != null; |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | } |