添加自动推荐标签功能

This commit is contained in:
nojava
2026-05-23 03:17:46 +08:00
parent 6e145d0980
commit 20b7a57fb9
16 changed files with 1182 additions and 9 deletions
@@ -7,10 +7,12 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.validation.FieldError;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.resource.NoResourceFoundException;
import java.util.stream.Collectors;
@@ -41,6 +43,19 @@ public class GlobalExceptionHandler {
return ApiResult.error(ErrorCode.FORBIDDEN);
}
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public ApiResult<Void> handleMethodNotSupported(HttpRequestMethodNotSupportedException e) {
log.warn("Method not supported: {}", e.getMessage());
return ApiResult.error(ErrorCode.METHOD_NOT_ALLOWED);
}
@ExceptionHandler(NoResourceFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ApiResult<Void> handleNoResourceFound(NoResourceFoundException e) {
return ApiResult.error(ErrorCode.NOT_FOUND);
}
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ApiResult<Void> handleException(Exception e) {