登录鉴权按照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());

View File

@@ -0,0 +1,15 @@
package com.aida.seller.common.exception;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class UnauthorizedException extends RuntimeException {
public UnauthorizedException(String message) {
super(message);
}
public UnauthorizedException() {
super("Gateway token verification failed");
}
}