瀏覽代碼

Merge branch '20211018_yw_check' into test_qiyuan

songxinlu 3 年之前
父節點
當前提交
0bd7eebae1
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/main/java/com/diagbot/config/AuthExceptionEntryPoint.java

+ 5 - 1
src/main/java/com/diagbot/config/AuthExceptionEntryPoint.java

@@ -1,5 +1,8 @@
 package com.diagbot.config;
 
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.exception.ServiceErrorCode;
 import com.diagbot.util.StringUtil;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.springframework.security.core.AuthenticationException;
@@ -27,12 +30,13 @@ public class AuthExceptionEntryPoint implements AuthenticationEntryPoint {
         if (StringUtil.isNotEmpty(authException.getMessage())&&authException.getMessage().contains("Access token expired")) {
             map.put("code", "10020011");
             map.put("msg", "登录超时。为确保您的账户安全,系统已自动退出,请重新登录。");
+            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
         }else {
+            response.setStatus(HttpServletResponse.SC_OK);
             map.put("code", "00000001");
             map.put("msg", authException.getMessage());
         }
         response.setContentType("application/json");
-        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
         try {
             ObjectMapper mapper = new ObjectMapper();
             mapper.writeValue(response.getOutputStream(), map);