From c277d1ef146793fe69cb3c3212fb10646841a7e3 Mon Sep 17 00:00:00 2001 From: zhouxiunai <154707516@qq.com> Date: Wed, 26 Dec 2018 14:40:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E6=9C=AA?= =?UTF-8?q?=E7=99=BB=E5=BD=95=EF=BC=8C=E7=8A=B6=E6=80=81=E7=A0=81=E6=9C=AA?= =?UTF-8?q?401?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adminapi/exception/handler/ExceptionHandle.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gzzn/omms/adminapi/exception/handler/ExceptionHandle.java b/src/main/java/com/gzzn/omms/adminapi/exception/handler/ExceptionHandle.java index f6a5592..b44df03 100644 --- a/src/main/java/com/gzzn/omms/adminapi/exception/handler/ExceptionHandle.java +++ b/src/main/java/com/gzzn/omms/adminapi/exception/handler/ExceptionHandle.java @@ -1,8 +1,5 @@ package com.gzzn.omms.adminapi.exception.handler; -import java.util.HashMap; -import java.util.Map; - import org.jboss.logging.MDC; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,7 +8,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; import com.gzzn.omms.adminapi.dto.ResponseDto; import com.gzzn.omms.adminapi.enums.ResultCode; @@ -26,15 +22,18 @@ public class ExceptionHandle { /** - * 用户不存在异常处理 + * 用户不存在异常处理,状态码401 * @param e * @return */ @ExceptionHandler(value = UserNoLoginException.class) @ResponseBody - public ResponseDto exceptionHandle(UserNoLoginException e) + public ResponseEntity> exceptionHandle(UserNoLoginException e) { - return ResponseDto.failure(ResultCode.USER_NOT_LOGGED_IN); + return new ResponseEntity>( + ResponseDto.failure(ResultCode.USER_NOT_LOGGED_IN), + HttpStatus.UNAUTHORIZED + ); }