xufeng 2 anos atrás
pai
commit
2278570303

+ 9 - 1
game-module/game-sdk/src/main/java/com/zanxiang/sdk/common/resolver/TokenArgumentResolver.java

@@ -44,6 +44,7 @@ public class TokenArgumentResolver implements HandlerMethodArgumentResolver {
         if (request == null) {
         if (request == null) {
             throw new CustomException(HttpStatusEnum.UNKNOWN_ERROR);
             throw new CustomException(HttpStatusEnum.UNKNOWN_ERROR);
         }
         }
+        //是否强制验证登录状态
         boolean b = parameter.hasParameterAnnotation(ValidLogin.class);
         boolean b = parameter.hasParameterAnnotation(ValidLogin.class);
         String token = request.getHeader("token");
         String token = request.getHeader("token");
         if (b && StringUtils.isEmpty(token)) {
         if (b && StringUtils.isEmpty(token)) {
@@ -54,15 +55,22 @@ public class TokenArgumentResolver implements HandlerMethodArgumentResolver {
         UserData data = new UserData();
         UserData data = new UserData();
         data.setDeviceType(deviceType);
         data.setDeviceType(deviceType);
         if (StringUtils.isEmpty(token)) {
         if (StringUtils.isEmpty(token)) {
+            if (b) {
+                throw new CustomException(HttpStatusEnum.USER_NO_LOGIN);
+            }
             return data;
             return data;
         }
         }
         UserTokenDTO tokenInfoByTokenDevice = userTokenService.getTokenInfoByTokenDevice(token, deviceType.toString());
         UserTokenDTO tokenInfoByTokenDevice = userTokenService.getTokenInfoByTokenDevice(token, deviceType.toString());
         if (tokenInfoByTokenDevice == null) {
         if (tokenInfoByTokenDevice == null) {
+            if (b) {
+                throw new CustomException(HttpStatusEnum.USER_NO_LOGIN);
+            }
             return data;
             return data;
         }
         }
         if (b && tokenInfoByTokenDevice.getUserId() == null) {
         if (b && tokenInfoByTokenDevice.getUserId() == null) {
             throw new CustomException(HttpStatusEnum.USER_NO_LOGIN);
             throw new CustomException(HttpStatusEnum.USER_NO_LOGIN);
         }
         }
-        return BeanUtils.copy(tokenInfoByTokenDevice, UserData.class);
+        data.setUserId(tokenInfoByTokenDevice.getUserId());
+        return data;
     }
     }
 }
 }

+ 1 - 1
game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/params/UserData.java

@@ -23,7 +23,7 @@ public class UserData implements Serializable {
 
 
 
 
     /**
     /**
-     * 设备类型;mobile,android,iphone,ipad,web,pc,mac,wxapp
+     * 设备类型;
      */
      */
     private Integer deviceType;
     private Integer deviceType;