登录鉴权按照Source判断id来自于何处

This commit is contained in:
litianxiang
2026-05-13 09:40:32 +08:00
parent 912d5efee7
commit daf40ab224
6 changed files with 120 additions and 20 deletions

View File

@@ -18,6 +18,15 @@ import java.util.stream.Collectors;
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(UnauthorizedException.class)
public ResponseEntity<Object> handleUnauthorizedException(UnauthorizedException e) {
log.error("Unauthorized: {}", e.getMessage());
return new ResponseEntity<>(
Response.fail(401, e.getMessage()),
HttpStatus.UNAUTHORIZED
);
}
@ExceptionHandler(BusinessException.class)
public Response<?> handleBusinessException(BusinessException e) {
log.error("业务异常: code={}, msg={}", e.getCode(), e.getMsg());