修改用户未登录,状态码未401

This commit is contained in:
zhouxiunai
2018-12-26 14:40:04 +08:00
parent a91075f1bb
commit c277d1ef14
@@ -1,8 +1,5 @@
package com.gzzn.omms.adminapi.exception.handler; package com.gzzn.omms.adminapi.exception.handler;
import java.util.HashMap;
import java.util.Map;
import org.jboss.logging.MDC; import org.jboss.logging.MDC;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; 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.dto.ResponseDto;
import com.gzzn.omms.adminapi.enums.ResultCode; import com.gzzn.omms.adminapi.enums.ResultCode;
@@ -26,15 +22,18 @@ public class ExceptionHandle {
/** /**
* 用户不存在异常处理 * 用户不存在异常处理,状态码401
* @param e * @param e
* @return * @return
*/ */
@ExceptionHandler(value = UserNoLoginException.class) @ExceptionHandler(value = UserNoLoginException.class)
@ResponseBody @ResponseBody
public ResponseDto exceptionHandle(UserNoLoginException e) public ResponseEntity<ResponseDto<String>> exceptionHandle(UserNoLoginException e)
{ {
return ResponseDto.failure(ResultCode.USER_NOT_LOGGED_IN); return new ResponseEntity<ResponseDto<String>>(
ResponseDto.failure(ResultCode.USER_NOT_LOGGED_IN),
HttpStatus.UNAUTHORIZED
);
} }