feat: add core schema and status enums

This commit is contained in:
王鹏
2026-07-07 15:10:03 +08:00
parent edffda2a84
commit 982f104f3d
13 changed files with 745 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package com.linhelp.common.exception;
import com.linhelp.common.api.ApiResponse;
import org.springframework.validation.BindException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(BizException.class)
public ApiResponse<Void> handleBizException(BizException exception) {
return ApiResponse.fail(exception.getCode(), exception.getMessage());
}
@ExceptionHandler({MethodArgumentNotValidException.class, BindException.class})
public ApiResponse<Void> handleValidationException(Exception exception) {
return ApiResponse.fail(422, "请求参数不正确");
}
@ExceptionHandler(Exception.class)
public ApiResponse<Void> handleException(Exception exception) {
return ApiResponse.fail(500, "系统繁忙,请稍后再试");
}
}