优化登录账号获取方法,优化定时器文案

This commit is contained in:
2026-06-12 08:44:57 +08:00
parent faa9549299
commit 56f0e4c509
3 changed files with 20 additions and 9 deletions
@@ -153,9 +153,22 @@ public class AuthUtils implements BaseParams {
* @return LoginUser
*/
public static LoginUserDto get() {
LoginUserDto dto = getDefNull();
if (Objects.isNull(dto)) {
throw new UnauthorizedError();
}
return dto;
}
/**
* 获取 LoginUser
*
* @return LoginUser
*/
public static LoginUserDto getDefNull() {
Map<String, Object> map = CommonHolder.get();
if (CollectionUtils.isEmpty(map)) {
throw new UnauthorizedError();
return null;
}
if (map.get(BootCommonConstant.AUTH) instanceof LoginUserDto loginUserDto) {
return loginUserDto;
@@ -163,7 +176,7 @@ public class AuthUtils implements BaseParams {
if (map.get(BootCommonConstant.AUTHORIZATION) instanceof String accessToken) {
return get(accessToken);
}
throw new UnauthorizedError();
return null;
}
/**