Parcourir la source

feat : 非嵌入式SDK接入, 接口提交3

bilingfeng il y a 11 mois
Parent
commit
a23eea2f9c

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/SDKApplication.java

@@ -23,7 +23,7 @@ public class SDKApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(SDKApplication.class, args);
-        System.out.println("赞象SDK服务启动成功 <非嵌入式SDK接入, 接口提交4> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <非嵌入式SDK接入, 接口提交5> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 9 - 24
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/adapter/WebHandlerAdapter.java

@@ -37,32 +37,17 @@ public class WebHandlerAdapter implements HandlerInterceptor {
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
         HandlerMethod handlerMethod = (HandlerMethod) handler;
-        //推送数据的签名校验
-        PushDataCheck[] pushDataChecks = handlerMethod.getMethod().getAnnotationsByType(PushDataCheck.class);
-        if (pushDataChecks.length != 0){
-            log.error("PushDataCheck注解拿到了, 长度为 : {}", pushDataChecks.length);
+        //数据推送请求加密验证
+        PushDataCheck pushDataCheck = handlerMethod.getMethod().getAnnotation(PushDataCheck.class);
+        if (pushDataCheck != null) {
             this.pushCheck(request);
         }
-        log.error("PushDataCheck注解为kong");
-        //排除签名认证接口注解
-        UnSignCheck[] unSignChecks = handlerMethod.getMethod().getAnnotationsByType(UnSignCheck.class);
-        if (unSignChecks.length != 0){
-            log.error("UnSignCheck注解拿到了, 长度为 : {}", unSignChecks.length);
-            return Boolean.TRUE;
+        //接口签名验证
+        UnSignCheck unSignCheck = handlerMethod.getMethod().getAnnotation(UnSignCheck.class);
+        if (unSignCheck == null) {
+            return this.signCheck(request);
         }
-        log.error("UnSignCheck注解为kong");
-        return this.signCheck(request);
-
-
-
-
-//        UnSignCheck unSignCheck = handlerMethod.getMethod().getAnnotation(UnSignCheck.class);
-//        //接口签名验证
-//        if (unSignCheck == null) {
-//            return this.signCheck(request);
-//        }
-//        log.error("UnSignCheck注解获取到不是kong");
-//        return Boolean.TRUE;
+        return Boolean.TRUE;
     }
 
     private boolean signCheck(HttpServletRequest request) throws Exception {
@@ -135,7 +120,7 @@ public class WebHandlerAdapter implements HandlerInterceptor {
         String mySign = SignUtil.MD5(str);
         //签名对比
         if (!Objects.equals(mySign, sign)) {
-            log.error("非法参数, 签名错误, mySign : {}, sign : {}, str : {}", mySign, sign, str);
+            log.error("非法参数, pushCheck签名错误, mySign : {}, sign : {}, str : {}", mySign, sign, str);
             throw new BaseException(HttpStatusEnum.INVALID_PARAMS.getMsg());
         }
     }

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/controller/PushController.java

@@ -57,7 +57,7 @@ public class PushController {
     }
 
     @UnSignCheck
-//    @PushDataCheck
+    @PushDataCheck
     @ApiOperation(value = "玩家注册 / 登录信息推送")
     @PostMapping("/cp/push/user")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})