mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-03-11 17:20:09 +08:00
update [重磅更新] 登录流程升级 支持缓存
This commit is contained in:
@@ -13,41 +13,13 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
* @author Long Li
|
||||
*/
|
||||
public class SecurityUtils {
|
||||
/**
|
||||
* 用户ID
|
||||
**/
|
||||
public static Long getUserId() {
|
||||
return LoginUtils.getUserId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门ID
|
||||
**/
|
||||
public static Long getDeptId() {
|
||||
try {
|
||||
return getUser().getDeptId();
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("获取部门ID异常", HttpStatus.HTTP_UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户账户
|
||||
**/
|
||||
public static String getUsername() {
|
||||
try {
|
||||
return getUser().getUserName();
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("获取用户账户异常", HttpStatus.HTTP_UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
**/
|
||||
public static SysUser getUser() {
|
||||
try {
|
||||
return SpringUtils.getBean(UserService.class).selectUserById(getUserId());
|
||||
return SpringUtils.getBean(UserService.class).selectUserById(LoginUtils.getUserId());
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("获取用户信息异常", HttpStatus.HTTP_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user