Procházet zdrojové kódy

修改 token过期返回的code

785834757 před 1 rokem
rodič
revize
ca58ffee0b

+ 7 - 6
commons/src/main/java/com/jzg/commons/core/base/BaseController.java

@@ -4,6 +4,7 @@ package com.jzg.commons.core.base;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.jzg.commons.exception.SystemException;
+import com.jzg.commons.exception.TokenExpireException;
 import jakarta.servlet.http.HttpServletRequest;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,7 +27,7 @@ public class BaseController {
         HttpServletRequest request = attributes.getRequest();
         String authorizationHeader = request.getHeader("Authorization");
         if(Objects.isNull(authorizationHeader) || Objects.isNull(redissonClient.getBucket(authorizationHeader).get())){
-            throw new SystemException("用户登录信息过期");
+            throw new TokenExpireException("用户登录信息过期");
         }
         String userJsonStr = redissonClient.getBucket(authorizationHeader).get().toString();
         JSONObject userInfo = JSONObject.parseObject(userJsonStr);
@@ -42,7 +43,7 @@ public class BaseController {
         HttpServletRequest request = attributes.getRequest();
         String authorizationHeader = request.getHeader("Authorization");
         if(Objects.isNull(authorizationHeader) || Objects.isNull(redissonClient.getBucket(authorizationHeader).get())){
-            throw new SystemException("用户登录信息过期");
+            throw new TokenExpireException("用户登录信息过期");
         }
         String userJsonStr = redissonClient.getBucket(authorizationHeader).get().toString();
         JSONObject userInfo = JSONObject.parseObject(userJsonStr);
@@ -58,7 +59,7 @@ public class BaseController {
         HttpServletRequest request = attributes.getRequest();
         String authorizationHeader = request.getHeader("Authorization");
         if(Objects.isNull(authorizationHeader) || Objects.isNull(redissonClient.getBucket(authorizationHeader).get())){
-            throw new SystemException("用户登录信息过期");
+            throw new TokenExpireException("用户登录信息过期");
         }
         List<String> userPerms = new ArrayList<>();
         String userJsonStr = redissonClient.getBucket(authorizationHeader).get().toString();
@@ -79,7 +80,7 @@ public class BaseController {
         HttpServletRequest request = attributes.getRequest();
         String authorizationHeader = request.getHeader("Authorization");
         if(Objects.isNull(authorizationHeader) || Objects.isNull(redissonClient.getBucket(authorizationHeader).get())){
-            throw new SystemException("用户登录信息过期");
+            throw new TokenExpireException("用户登录信息过期");
         }
         String userJsonStr = redissonClient.getBucket(authorizationHeader).get().toString();
         JSONObject userInfo = JSONObject.parseObject(userJsonStr);
@@ -91,7 +92,7 @@ public class BaseController {
         HttpServletRequest request = attributes.getRequest();
         String authorizationHeader = request.getHeader("Authorization");
         if(Objects.isNull(authorizationHeader) || Objects.isNull(redissonClient.getBucket(authorizationHeader).get())){
-            throw new SystemException("用户登录信息过期");
+            throw new TokenExpireException("用户登录信息过期");
         }
         String userJsonStr = redissonClient.getBucket(authorizationHeader).get().toString();
         JSONObject userInfo = JSONObject.parseObject(userJsonStr);
@@ -107,7 +108,7 @@ public class BaseController {
         HttpServletRequest request = attributes.getRequest();
         String authorizationHeader = request.getHeader("Authorization");
         if(Objects.isNull(authorizationHeader) || Objects.isNull(redissonClient.getBucket(authorizationHeader).get())){
-            throw new SystemException("用户登录信息过期");
+            throw new TokenExpireException("用户登录信息过期");
         }
         String userJsonStr = redissonClient.getBucket(authorizationHeader).get().toString();
         JSONObject userInfo = JSONObject.parseObject(userJsonStr);