From 77e4741346fb02d5a1f845b89f681a56d06dad0e Mon Sep 17 00:00:00 2001 From: 安瑾然 <107107765@qq.com> Date: 星期二, 12 七月 2022 14:59:29 +0800 Subject: [PATCH] minio接口修正,宣传、常见问题接口开发 --- src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java b/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java index c153ac9..ce97b0b 100644 --- a/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java +++ b/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java @@ -1,9 +1,7 @@ package com.example.jz.config; -import com.example.jz.enums.BusinessHttpStatus; import com.example.jz.exception.BusinessException; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; +import com.example.jz.modle.R; import org.springframework.stereotype.Controller; import org.springframework.validation.BindException; import org.springframework.web.bind.MethodArgumentNotValidException; @@ -19,21 +17,21 @@ @ExceptionHandler(BindException.class) - public ResponseEntity<String> bindExceptionHandler(BindException e) { + public R<String> bindExceptionHandler(BindException e) { e.printStackTrace(); - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()); + return R.failed(e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()); } @ExceptionHandler(MethodArgumentNotValidException.class) - public ResponseEntity<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { + public R<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { e.printStackTrace(); - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()); + return R.failed(e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()); } @ExceptionHandler(BusinessException.class) - public ResponseEntity<String> unauthorizedExceptionHandler(BusinessException e) { + public R<String> unauthorizedExceptionHandler(BusinessException e) { e.printStackTrace(); - return ResponseEntity.status(e.getHttpStatusCode()).body(e.getMessage()); + return R.failed(e.getMessage()); } } -- Gitblit v1.8.0