update [重磅更新] 登录流程升级 支持缓存

This commit is contained in:
疯狂的狮子li
2021-12-03 18:46:49 +08:00
parent 5a271b8fde
commit e763381186
19 changed files with 179 additions and 105 deletions

View File

@@ -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);
}