|
@@ -49,26 +49,24 @@ public class ServiceExceptionHandler {
|
|
|
/**
|
|
|
* 验证异常处理 - 在 @RequestBody 上添加 @Validated 处触发
|
|
|
*
|
|
|
- * @param request {@link HttpServletRequest}
|
|
|
- * @param e {@link MethodArgumentNotValidException}
|
|
|
+ * @param e {@link MethodArgumentNotValidException}
|
|
|
*/
|
|
|
@ExceptionHandler({MethodArgumentNotValidException.class})
|
|
|
@ResponseStatus(HttpStatus.OK)
|
|
|
@ResponseBody
|
|
|
- public ApiResult handleMethodArgumentNotValidException(HttpServletRequest request, MethodArgumentNotValidException e) {
|
|
|
+ public ApiResult<String> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
|
|
return ApiResult.failed(this.convertFiledErrors(e.getBindingResult().getFieldErrors()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 验证异常处理 - form参数(对象参数,没有加 @RequestBody)触发
|
|
|
*
|
|
|
- * @param request {@link HttpServletRequest}
|
|
|
- * @param e {@link BindException}
|
|
|
+ * @param e {@link BindException}
|
|
|
*/
|
|
|
@ExceptionHandler({BindException.class})
|
|
|
@ResponseStatus(HttpStatus.OK)
|
|
|
@ResponseBody
|
|
|
- public ApiResult handleBindException(HttpServletRequest request, BindException e) {
|
|
|
+ public ApiResult<String> handleBindException(BindException e) {
|
|
|
return ApiResult.failed(this.convertFiledErrors(e.getBindingResult().getFieldErrors()));
|
|
|
}
|
|
|
|
|
@@ -82,7 +80,7 @@ public class ServiceExceptionHandler {
|
|
|
@ExceptionHandler({ConstraintViolationException.class})
|
|
|
@ResponseStatus(HttpStatus.OK)
|
|
|
@ResponseBody
|
|
|
- public ApiResult handleConstraintViolationException(HttpServletRequest request, ConstraintViolationException ex) {
|
|
|
+ public ApiResult<String> handleConstraintViolationException(HttpServletRequest request, ConstraintViolationException ex) {
|
|
|
return ApiResult.failed(this.convertConstraintViolations(ex));
|
|
|
}
|
|
|
|