Ver código fonte

全链路:::::ip+黑白名单+访问限制-v0.07

MOKASZ\lw12420 1 ano atrás
pai
commit
433b39161e

+ 24 - 20
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewCommonOutController.java

@@ -186,17 +186,8 @@ public class PlanNewCommonOutController {
         });
         // GZIP压缩
        // Mono<byte[]> res = resMono.flatMap(f -> Mono.just(Objects.requireNonNull(this.compressData(JSONUtil.toJsonStr(f)))));
-        Mono<Boolean> rateReturn = blacklistService.getRateReturn(exchange,unique);
-        return rateReturn.flatMap(bl->{
-            if(bl){
-                return  RStatus.success(resMono) ;
-            }else {
-                PlanNewCommonRes dataLists = new PlanNewCommonRes();
-                dataLists.setWxUrl(BlacklistService.wxUrl.get());
-                return RStatus.fail("1","",Mono.just(dataLists));
-            }
-        });
-       // return RStatus.success(resMono);
+
+        return RStatus.success(resMono);
     }
 
     /**
@@ -497,25 +488,38 @@ public class PlanNewCommonOutController {
      * @return {@link Mono}<{@link RStatus}<{@link DomainSelectRes}>>
      */
     @PostMapping("domainSelect")
-    public Mono<RStatus<DomainSelectRes>> domainSelect(@RequestBody OutDomainRequest request) {
-        if (null == request.getCode() || request.getCode().isEmpty()) {
-            return Mono.error(new BaseException("code为空"));
-        }
+
+    public Mono<RStatus<DomainSelectRes>> domainSelect(@RequestBody OutDomainRequest request, ServerWebExchange exchange) {
+            if (null == request.getCode() || request.getCode().isEmpty()) {
+                return Mono.error(new BaseException("code为空"));
+            }
+        Mono<RStatus<DomainSelectRes>> planNew;
+
         if (1 == request.getTypePlan()) {
             // 加群裂变
-            return this.getPlanNew(request);
+             planNew = this.getPlanNew(request);
         } else if (2 == request.getTypePlan()) {
             // 听书裂变
-            return this.getListeningPlan(request);
+            planNew = this.getListeningPlan(request);
         } else if (3 == request.getTypePlan() ||6 == request.getTypePlan() ||7 == request.getTypePlan()) {
             // 交友裂变
-            return this.getFriendPlan(request);
+            planNew = this.getFriendPlan(request);
         } else if (4 == request.getTypePlan()) {
-            return this.getTakeaway(request);
+            planNew = this.getTakeaway(request);
         }else{
             // 交友裂变
-            return this.getFriendPlan(request);
+            planNew = this.getFriendPlan(request);
         }
+        Mono<Boolean> rateReturn = blacklistService.getRateReturn(exchange);
+        return rateReturn.flatMap(bl->{
+            if(bl){
+                return  planNew ;
+            }else {
+                DomainSelectRes dataLists = new DomainSelectRes();
+                dataLists.setWxUrl(BlacklistService.wxUrl.get());
+                return RStatus.fail("1","",Mono.just(dataLists));
+            }
+        });
        // throw new BaseException("typePlan 类型错误");
     }
 

+ 2 - 2
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewOutController.java

@@ -194,7 +194,7 @@ public class PlanNewOutController {
                     return Mono.just(domainSelectRes);
                 });
             });
-            Mono<Boolean> rateReturn = blacklistService.getRateReturn(exchange,null);
+            Mono<Boolean> rateReturn = blacklistService.getRateReturn(exchange);
             return rateReturn.flatMap(bl->{
                 if(bl){
                     return  RStatus.successList(domainSelectResMono1) ;
@@ -207,7 +207,7 @@ public class PlanNewOutController {
           //  return RStatus.success(domainSelectResMono1);
         }else  if(2==typePlan){
 
-            Mono<Boolean> rateReturn = blacklistService.getRateReturn(exchange,null);
+            Mono<Boolean> rateReturn = blacklistService.getRateReturn(exchange);
             return rateReturn.flatMap(bl->{
                 if(bl){
                     Long start = System.currentTimeMillis();

+ 1 - 1
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/testController.java

@@ -76,7 +76,7 @@ public class testController {
     }
     @GetMapping("get51")
     public Mono<Boolean>  get51(ServerWebExchange exchange)   {
-        Mono<Boolean> rateReturn = blacklistService.getRateReturn(exchange,null);
+        Mono<Boolean> rateReturn = blacklistService.getRateReturn(exchange);
         return rateReturn;
     }
     @GetMapping("get5")

+ 2 - 8
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/ip/BlacklistService.java

@@ -51,7 +51,7 @@ public class BlacklistService {
      * @param exchange
      * @return
      */
-    public Mono<Boolean> getRateReturn(ServerWebExchange exchange,String unique){
+    public Mono<Boolean> getRateReturn(ServerWebExchange exchange){
         ServerHttpRequest httpRequest = exchange.getRequest();
         InetSocketAddress remoteAddress = httpRequest.getRemoteAddress();
         String ipAddress;
@@ -62,13 +62,7 @@ public class BlacklistService {
         }
         if (Objects.nonNull(ipAddress)) {
             try {
-                return getFrist( unique).flatMap(f->{
-                    if (f) {
-                      return getIpRateNum(ipAddress);
-                    }else {
-                      return Mono.just(true);
-                    }
-                }) ;
+                return getIpRateNum(ipAddress);
             }catch (Exception e){
                 log.error("ip黑名单验证:" +ipAddress+"::Error:::"+e.getMessage());
                 return Mono.just(false);