使用 UnifiedResponse 替代 RestfulResult

This commit is contained in:
2023-09-09 18:38:09 +08:00
parent 208d7c93c9
commit b25d7589c2
11 changed files with 72 additions and 68 deletions

View File

@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import lombok.extern.slf4j.Slf4j;
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
import xyz.zhouxy.plusone.commons.util.RestfulResult;
import xyz.zhouxy.plusone.commons.util.UnifiedResponse;
/**
* 默认异常的处理器
@@ -62,7 +62,7 @@ public class DefaultExceptionHandler extends BaseExceptionHandler {
DataAccessException.class,
MethodArgumentNotValidException.class
})
public ResponseEntity<RestfulResult> handleException(Exception e) {
public ResponseEntity<UnifiedResponse> handleException(Exception e) {
log.error(e.getMessage(), e);
return buildExceptionResponse(e);
}

View File

@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import lombok.extern.slf4j.Slf4j;
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
import xyz.zhouxy.plusone.commons.util.RestfulResult;
import xyz.zhouxy.plusone.commons.util.UnifiedResponse;
import xyz.zhouxy.plusone.exception.SysException;
@RestControllerAdvice
@@ -21,9 +21,9 @@ public class SysExceptionHandler extends BaseExceptionHandler {
}
@ExceptionHandler({ SysException.class })
public ResponseEntity<RestfulResult> handleException(@Nonnull Exception e) {
public ResponseEntity<UnifiedResponse> handleException(@Nonnull Exception e) {
log.error(e.getMessage(), e);
HttpStatus httpStatus = getHttpStatus(e);
return new ResponseEntity<>(RestfulResult.error(getErrorCode(e), "系统错误"), httpStatus);
return new ResponseEntity<>(UnifiedResponse.error(getErrorCode(e), "系统错误"), httpStatus);
}
}