mirror of
https://gitee.com/dromara/dax-pay
synced 2026-08-10 06:46:04 +08:00
feat: 基础脚手架更新
This commit is contained in:
@@ -18,6 +18,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.http.converter.HttpMessageConversionException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
@@ -86,6 +87,19 @@ public class RestExceptionHandler {
|
||||
return Res.response(CommonErrorCode.VALIDATE_PARAMETERS_ERROR, message.toString(), MDC.get(CommonCode.TRACE_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求参数校验未通过
|
||||
*/
|
||||
@ExceptionHandler({ MethodArgumentNotValidException.class })
|
||||
public Result<Void> handleBusinessException(MethodArgumentNotValidException ex) {
|
||||
log.info(ex.getMessage(), ex);
|
||||
StringBuilder message = new StringBuilder();
|
||||
for (var violation : ex.getAllErrors()) {
|
||||
message.append(violation.getDefaultMessage()).append(System.lineSeparator());
|
||||
}
|
||||
return Res.response(CommonErrorCode.VALIDATE_PARAMETERS_ERROR, message.toString(), MDC.get(CommonCode.TRACE_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* 不支持 HTTP 请求方法异常
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user