Преглед изворни кода

Merge branch 'dev-w' into test

# Conflicts:
#	launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewCommonOutController.java
#	launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewOutController.java
#	launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/listening/ListeningPlanServiceImpl.java
wangcheng пре 2 година
родитељ
комит
e23a6d98d1
14 измењених фајлова са 444 додато и 214 уклоњено
  1. 0 1
      launch-admin/pom.xml
  2. 5 3
      launch-admin/src/main/java/com/webflux/launchadmin/filter/TraceIdFilter.java
  3. 99 7
      launch-admin/src/main/java/com/webflux/launchadmin/global/GlobalExceptionHandler.java
  4. 3 3
      launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewCommonController.java
  5. 90 89
      launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewCommonOutController.java
  6. 8 8
      launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewController.java
  7. 68 49
      launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewOutController.java
  8. 23 18
      launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/listening/ListeningPlanServiceImpl.java
  9. 29 2
      launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/planNew/PlanServiceImpl.java
  10. 1 0
      launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/planNew/PlanServiceInterface.java
  11. 23 18
      launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/planNew/goGenerate/GoGenerateService.java
  12. 77 0
      launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/userVisits/UserVisitsServices.java
  13. 15 16
      launch-common/src/main/java/com/webflux/launchcommon/returnObj/RW.java
  14. 3 0
      launch-redis/src/main/java/com/weblux/launchredis/utils/RedisKey.java

+ 0 - 1
launch-admin/pom.xml

@@ -141,7 +141,6 @@
             <groupId>com.launch.webflux</groupId>
             <artifactId>launch-elasticsearch</artifactId>
         </dependency>
-
     </dependencies>
     <build>
         <plugins>

+ 5 - 3
launch-admin/src/main/java/com/webflux/launchadmin/filter/TraceIdFilter.java

@@ -2,6 +2,7 @@ package com.webflux.launchadmin.filter;
 
 import com.plumelog.core.TraceId;
 import lombok.SneakyThrows;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.http.server.reactive.ServerHttpRequest;
 import org.springframework.stereotype.Component;
 import org.springframework.web.server.ServerWebExchange;
@@ -20,14 +21,15 @@ public class TraceIdFilter implements WebFilter {
     public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
         try {
             ServerHttpRequest request = exchange.getRequest();
-            String traceId = request.getQueryParams().getFirst("traceId");
+            String traceId = request.getHeaders().getFirst("Trace-Id");
             if (traceId == null || traceId.isEmpty()) {
                 TraceId.set();
             } else {
                 TraceId.logTraceID.set(traceId);
             }
-        } finally {
-            return chain.filter(exchange);
+        } catch (Exception e) {
+            TraceId.set();
         }
+        return chain.filter(exchange);
     }
 }

+ 99 - 7
launch-admin/src/main/java/com/webflux/launchadmin/global/GlobalExceptionHandler.java

@@ -1,24 +1,116 @@
 package com.webflux.launchadmin.global;
 
-import com.alibaba.cola.dto.Response;
-import com.webflux.launchcommon.returnObj.RStatus;
+import com.alibaba.fastjson.JSON;
+import com.plumelog.core.util.LogExceptionStackTrace;
 import com.webflux.launchcommon.returnObj.RW;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.dao.DataAccessException;
 import org.springframework.http.HttpStatus;
+import org.springframework.util.MultiValueMap;
+import org.springframework.validation.BindException;
+import org.springframework.web.bind.MethodArgumentNotValidException;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.ResponseStatus;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.multipart.MaxUploadSizeExceededException;
+import org.springframework.web.reactive.resource.NoResourceFoundException;
+import org.springframework.web.server.MethodNotAllowedException;
+import org.springframework.web.server.MissingRequestValueException;
+import org.springframework.web.server.ServerWebExchange;
 import reactor.core.publisher.Mono;
 
+import javax.security.auth.login.AccountExpiredException;
+import java.nio.file.AccessDeniedException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @author moka
+ */
 @RestControllerAdvice
 @Slf4j
 public class GlobalExceptionHandler {
-    @ResponseBody
-    @ResponseStatus(HttpStatus.BAD_REQUEST)
+    @ExceptionHandler(BaseException.class)
+    public Mono<RW<Object>> handleException(ServerWebExchange exchange, BaseException e) {
+        log.warn("接口异常 uri={} e={}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
+        return RW.fail("500", e.getMessage(), Mono.just(e.getMessage()));
+    }
+
+    /**
+     * 文件上传异常
+     */
+    @ExceptionHandler(MaxUploadSizeExceededException.class)
+    public Mono<RW<Object>> baseException(MaxUploadSizeExceededException e) {
+        return RW.fail("文件大小超出限制,请修改后重新上传。", Mono.just(e.getMessage()));
+    }
+
+    @ExceptionHandler(AccessDeniedException.class)
+    public Mono<RW<Object>> handleAuthorizationException(ServerWebExchange exchange, AccessDeniedException e) {
+        log.warn("接口异常 uri = {} e = {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
+        return RW.fail(HttpStatus.FORBIDDEN.toString(), "没有权限,请联系管理员授权", Mono.just(e.getMessage()));
+    }
+
+    //@ResponseStatus(HttpStatus.BAD_REQUEST)
+    @ExceptionHandler(MissingRequestValueException.class)
+    public Mono<RW<Object>> handleMissingRequestValueException(ServerWebExchange exchange, MissingRequestValueException e) {
+        log.warn("接口异常 uri = {} e = {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
+        return RW.fail(HttpStatus.FORBIDDEN.toString(), "请求参数异常", Mono.just(e.getMessage()));
+    }
+
+    @ExceptionHandler(AccountExpiredException.class)
+    public Mono<RW<Object>> handleAccountExpiredException(ServerWebExchange exchange, AccountExpiredException e) {
+        log.warn("接口异常 uri = {} e = {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
+        return RW.fail(e.getMessage(), Mono.just(e.getMessage()));
+    }
+
+    @ExceptionHandler(DataAccessException.class)
+    public Mono<RW<Object>> handleDataAccessException(ServerWebExchange exchange, DataAccessException e) {
+        log.error("接口异常 uri = {} e = {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
+        return RW.fail(e.getMessage(), Mono.just(e.getMessage()));
+    }
+
     @ExceptionHandler(Exception.class)
-    public Mono<RW<Object>> handleException(Exception e) {
-        log.error(e.toString());
-        return RW.fail("500",e.getMessage(),Mono.just(e.getMessage()));
+    public Mono<RW<Object>> handleException(ServerWebExchange exchange, Exception e) {
+        if (e instanceof BaseException
+                || e instanceof NoResourceFoundException
+                || e instanceof MethodNotAllowedException) {
+            try {
+                Map<String, Object> logger = new HashMap<>();
+                MultiValueMap<String, String> queryParams = exchange.getRequest().getQueryParams();
+                logger.put("param", queryParams);
+                String paramStr = JSON.toJSONString(logger);
+                log.info("裂变项目api请求记录:{}:{}", exchange.getRequest().getPath().value(), paramStr);
+            } catch (Exception e1) {
+                log.warn("裂变项目api请求记录异常:{}", LogExceptionStackTrace.erroStackTrace(e1));
+            }
+            log.warn("接口异常 uri= {} e= {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
+        } else {
+            log.error("接口异常 uri = {} e = {}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
+        }
+        return RW.fail(e.getMessage(), Mono.just(e.getMessage()));
+    }
+
+    /**
+     * 自定义验证异常
+     */
+    @ExceptionHandler(BindException.class)
+    public Mono<RW<Object>> validatedBindException(ServerWebExchange exchange, BindException e) {
+        log.warn("接口异常 uri={} e={}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
+        String message = e.getAllErrors().getFirst().getDefaultMessage();
+        assert message != null;
+        return RW.fail(message, Mono.just(message));
+    }
+
+    /**
+     * 自定义验证异常
+     */
+    @ExceptionHandler(MethodArgumentNotValidException.class)
+    public Mono<RW<Object>> validExceptionHandler(ServerWebExchange exchange, MethodArgumentNotValidException e) {
+        log.warn("接口异常 uri={} e={}", exchange.getRequest().getPath().value(), LogExceptionStackTrace.erroStackTrace(e));
+        String message = Objects.requireNonNull(e.getBindingResult().getFieldError()).getDefaultMessage();
+        assert message != null;
+        return RW.fail(message, Mono.just(message));
     }
 }

+ 3 - 3
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewCommonController.java

@@ -157,7 +157,7 @@ public class PlanNewCommonController {
                 .select(Query.query(Criteria.where("poster_template_id").is(planReq.getPosterTemplateId()))
                         .sort(Sort.by(Sort.Order.asc("created_at"))), Poster.class)
                 .switchIfEmpty(Mono.error(new BaseException("未查询到海报模版")))
-                .onErrorResume(throwable -> Mono.error(new Exception("未查询到海报模版")))
+                .onErrorResume(throwable -> Mono.error(new BaseException("未查询到海报模版")))
                 .collectList().flatMap(f -> {
                     Poster poster = f.getFirst();
                     String posterTemplate = poster.posterTemplate();
@@ -227,7 +227,7 @@ public class PlanNewCommonController {
             // 交友计划
             Mono<PlanNewCommon> planNewCommonMono = template.selectOne(Query.query(Criteria.where("id").is(planId)), PlanNewCommon.class)
                     .switchIfEmpty(Mono.error(new BaseException("计划id异常")))
-                    .onErrorResume(throwable -> Mono.error(new Exception("计划id异常")));
+                    .onErrorResume(throwable -> Mono.error(new BaseException("计划id异常")));
             return RStatus.success(planNewCommonMono);
 
     }
@@ -319,7 +319,7 @@ public class PlanNewCommonController {
             Query plan = Query.query(Criteria.where("id").is(planId));
             Mono<Long> planNewCommon = template.delete(plan, PlanNewCommon.class)
                     .switchIfEmpty(Mono.error(new BaseException("计划id异常")))
-                    .onErrorResume(throwable -> Mono.error(new Exception("删除计划 " + planId + "---" + type + "error:" + throwable.getMessage())));
+                    .onErrorResume(throwable -> Mono.error(new BaseException("删除计划 " + planId + "---" + type + "error:" + throwable.getMessage())));
             Query planNewId = Query.query(Criteria.where("plan_new_id").is(planId));
             Mono<Long> poster = template.count(planNewId, PlanNewBackgroupPoster.class).filter(f -> f > 0)
                     .flatMap(f -> template.delete(planNewId, PlanNewBackgroupPoster.class))

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

@@ -7,15 +7,18 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
+import com.plumelog.core.util.LogExceptionStackTrace;
 import com.webflux.launchadmin.global.BaseException;
-import com.webflux.launchadmin.mysql.controller.planNew.req.*;
+import com.webflux.launchadmin.mysql.controller.planNew.req.KefuRequest;
+import com.webflux.launchadmin.mysql.controller.planNew.req.OutDomainRequest;
+import com.webflux.launchadmin.mysql.controller.planNew.req.PlanNewCommonMaterialReq;
+import com.webflux.launchadmin.mysql.controller.planNew.req.PlanNewCommonShareReq;
 import com.webflux.launchadmin.mysql.controller.planNew.res.*;
 import com.webflux.launchadmin.mysql.controller.takeawayController.res.TakeawayH5Data;
 import com.webflux.launchadmin.mysql.entity.groupUsers.GroupUsers;
 import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
 import com.webflux.launchadmin.mysql.entity.planNew.*;
-import com.webflux.launchadmin.mysql.entity.redis.RedisKey;
+import com.webflux.launchadmin.mysql.service.planNew.PlanServiceInterface;
 import com.webflux.launchadmin.mysql.service.planNew.goGenerate.GoGenerateService;
 import com.webflux.launchadmin.mysql.service.planNew.ipAnalyze.IpAnalyzeServiceInterface;
 import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
@@ -24,16 +27,12 @@ import com.webflux.launchadmin.mysql.service.takeaway.TakeawayServicesInterface;
 import com.webflux.launchcommon.returnObj.RStatus;
 import com.webflux.launchcommon.utils.StringUtils;
 import jakarta.annotation.Resource;
-import jakarta.json.Json;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
-import org.springframework.data.redis.core.ReactiveRedisTemplate;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.data.relational.core.query.Criteria;
 import org.springframework.data.relational.core.query.Query;
-import org.springframework.http.server.reactive.ServerHttpRequest;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.server.ServerWebExchange;
 import reactor.core.publisher.Mono;
@@ -62,19 +61,22 @@ public class PlanNewCommonOutController {
     @Resource
     private GoGenerateService goGenerateService;
     @Resource
-    private ReactiveRedisTemplate<String, Object> reactiveRedisTemplate;
+    private StringRedisTemplate stringRedisTemplate;
     @Resource
     private TakeawayServicesInterface takeawayServicesInterface;
     @Resource
     private IpAnalyzeServiceInterface ipAnalyzeServiceInterface;
+    @Resource
+    private PlanServiceInterface planServiceInterface;
     private static final ConcurrentHashMap<String, Integer> MAP = new ConcurrentHashMap<>();
 
-    @Scheduled(cron = "1 1 4 * * ?")
-    public void clearUserContextHashMap() {
-        log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》开始");
-        MAP.clear();
-        log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》 结束");
-    }
+    // @Scheduled(cron = "1 1 4 * * ?")
+    // @SchedulerLock(name = "launch:PlanNewCommonOutController:clearUserContextHashMap", lockAtLeastFor = "PT5S", lockAtMostFor = "PT15M")
+    // public void clearUserContextHashMap() {
+    //     log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》开始");
+    //     MAP.clear();
+    //     log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》 结束");
+    // }
 
     /**
      * 通过 code 获取计划配置H5信息
@@ -87,8 +89,8 @@ public class PlanNewCommonOutController {
 
 
         Mono<PlanNewCommon> planNewCommonMono = template.selectOne(Query.query(Criteria.where("code").is(code)), PlanNewCommon.class)
-                .switchIfEmpty(Mono.error(new BaseException("计划code异")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "1")));
+                .switchIfEmpty(Mono.error(new BaseException("计划code异")))
+                .onErrorResume(throwable -> Mono.error(new BaseException("计划code异")));
         Mono<PlanNewCommonRes> resMono = planNewCommonMono.flatMap(f -> {
             // 群成员
             Mono<List<GroupUserRes>> groupUserResMono = Mono.just(new ArrayList<>());
@@ -96,16 +98,16 @@ public class PlanNewCommonOutController {
             Mono<List<Image>> imageMono = template.select(Query.query(Criteria.where("type").is(1)
                             .and("group_type_id").is(f.groupId())
                             .and("deleted_at").isNull()), Image.class)
-                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "2"))).collectList();
+                    .onErrorResume(throwable -> Mono.error(new BaseException("获取群封面异常"))).collectList();
             // 群名称
             Mono<List<Material>> textMono = template.select(Query.query(Criteria.where("type").is(4)
                             .and("deleted_at").isNull()
                             .and("group_type_id").is(f.groupId())), Material.class)
-                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "3"))).collectList();
+                    .onErrorResume(throwable -> Mono.error(new BaseException("获取群名称异常"))).collectList();
             if (3 == f.type()) {
                 // 交友裂变, 需要群成员
                 Mono<List<GroupUsers>> groupUsersMono = template.select(Query.query(Criteria.where("group_users_type").is(f.groupId())).limit(14), GroupUsers.class)
-                        .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "4"))).collectList();
+                        .onErrorResume(throwable -> Mono.error(new BaseException("获取群成员异常"))).collectList();
                 groupUserResMono = groupUsersMono.flatMap(groupUsers -> {
                     List<GroupUserRes> groupUserResList = groupUsers.stream().map(groupUsers1 -> {
                         GroupUserRes groupUserRes = new GroupUserRes();
@@ -195,7 +197,7 @@ public class PlanNewCommonOutController {
     public Mono<RStatus<byte[]>> kefuList(@RequestBody KefuRequest request) {
         Mono<PlanNewCommon> code = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNewCommon.class)
                 .switchIfEmpty(Mono.error(new BaseException("code查询返回结构为空")))
-                .onErrorResume(throwable -> Mono.error(new Exception("通过code查询计划异常::" + throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException("code查询返回结构为空")));
         Mono<DataListsKefu> dataListsKefuMono = code.flatMap(planNew -> {
             Mono<List<Image>> image = template.select(Query.query(Criteria.where("type").is(5)
                             .and("deleted_at").isNull()
@@ -203,13 +205,13 @@ public class PlanNewCommonOutController {
                     .collectList()
                     .switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Image返回结构为空", planNew.groupId()))))
                     .onErrorResume(throwable ->
-                            Mono.error(new Exception(StrUtil.format("通过计划groupId:{}查询Image返回结果error:{}", planNew.groupId(), throwable.getMessage()))));
+                            Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Image返回结果error:{}", planNew.groupId(), LogExceptionStackTrace.erroStackTrace(throwable).toString()))));
             Mono<List<Material>> text = template.select(Query.query(Criteria.where("type").is(11)
                             .and("group_type_id").is(planNew.groupId())
                             .and("deleted_at").isNull()), Material.class)
                     .switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Material返回结构为空", planNew.groupId()))))
                     .onErrorResume(throwable ->
-                            Mono.error(new Exception(StrUtil.format("通过计划groupId:{}查询Material返回结果error:{}", planNew.groupId(), throwable.getMessage()))))
+                            Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Material返回结果error:{}", planNew.groupId(), LogExceptionStackTrace.erroStackTrace(throwable).toString()))))
                     .collectList();
             Mono<List<H5ImageAndText>> arrayListMono = Mono.zip(Mono.just(planNew), image, text).flatMap(f -> {
                 // H5ImageAndText
@@ -218,7 +220,7 @@ public class PlanNewCommonOutController {
                 List<Image> t3 = f.getT2();
                 List<Material> t4 = f.getT3();
                 if (t3.size() < integer || t4.size() < integer) {
-                    throw new BaseException("图片或文字素材小于计划设置数");
+                    return Mono.error(new BaseException("图片或文字素材小于计划设置数"));
                 }
                 ArrayList<Long> listImg = new ArrayList<>();
                 ArrayList<Long> listTxt = new ArrayList<>();
@@ -288,10 +290,10 @@ public class PlanNewCommonOutController {
         } else if (2 == request.getTypePlan()) {
             // 听书裂变
             return this.getListeningPlan(request);
-        } else if(3==request.getTypePlan()){
+        } else if (3 == request.getTypePlan()) {
             // 交友裂变
             return this.getFriendPlan(request);
-        }else if(4==request.getTypePlan()){
+        } else if (4 == request.getTypePlan()) {
             return this.getTakeaway(request);
         }
         throw new BaseException("typePlan 类型错误");
@@ -304,7 +306,7 @@ public class PlanNewCommonOutController {
         Mono<PlanNew> code1 = template
                 .selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNew.class)
                 .switchIfEmpty(Mono.error(new BaseException("计划code异常 返回结果为空")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException("计划code异常" + throwable.getMessage())));
         Mono<DomainSelectRes> domainSelectResMono1 = code1.flatMap(f -> {
             Mono<String> stringMono;
             if (f.transferPageBl() == 1 && Objects.nonNull(f.transferPageDomain())) {
@@ -314,7 +316,7 @@ public class PlanNewCommonOutController {
                                 .and("type").is(5)
                                 .and("deleted_at").isNull()), DomainSelect.class)
                         .switchIfEmpty(Mono.error(new BaseException("transferPageDomain 域名查詢為空 group_type_id:::" + f.transferPageDomain())))
-                        .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fff -> {
+                        .onErrorResume(throwable -> Mono.error(new BaseException("transferPageDomain 域名查詢為空 group_type_id:::" + f.transferPageDomain()))).collectList().flatMap(fff -> {
                             if (!fff.isEmpty()) {
                                 DomainSelect domainSelect = fff.get(RandomUtil.randomInt(0, fff.size()));
                                 String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
@@ -322,7 +324,7 @@ public class PlanNewCommonOutController {
                                 return Mono.just(string + "." + domain1);
 
                             } else {
-                                throw new BaseException("transferPageDomain 中轉域名查詢為空 group_type_id:::" + f.transferPageDomain());
+                                return Mono.error(new BaseException("transferPageDomain 中轉域名查詢為空 group_type_id:::" + f.transferPageDomain()));
                             }
                         });
             } else {
@@ -336,14 +338,14 @@ public class PlanNewCommonOutController {
                                 .and("type").is(4)
                                 .and("deleted_at").isNull()), DomainSelect.class)
                         .switchIfEmpty(Mono.error(new BaseException("backgroupDomain 域名查询为空 group_type_id" + f.backgroupDomain())))
-                        .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fff -> {
+                        .onErrorResume(throwable -> Mono.error(new BaseException("backgroupDomain 域名查询为空 group_type_id" + f.backgroupDomain()))).collectList().flatMap(fff -> {
                             if (!fff.isEmpty()) {
                                 DomainSelect domainSelect = fff.get(RandomUtil.randomInt(0, fff.size()));
                                 String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
                                 String domain1 = domainSelect.domain();
                                 return Mono.just(string + "." + domain1);
                             } else {
-                                throw new BaseException("backgroupDomain 背景域名查詢為空 group_type_id" + f.backgroupDomain());
+                                return Mono.error(new BaseException("backgroupDomain 背景域名查詢為空 group_type_id" + f.backgroupDomain()));
                             }
                         });
             } else {
@@ -355,7 +357,7 @@ public class PlanNewCommonOutController {
                             .and("type").is(request.getType())
                             .and("deleted_at").isNull()), DomainSelect.class)
                     .switchIfEmpty(Mono.error(new BaseException("查询domain 返回结果为空")))
-                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fm -> {
+                    .onErrorResume(throwable -> Mono.error(new BaseException("查询domain 返回结果为空"))).collectList().flatMap(fm -> {
                         //  DomainSelectRes domainSelectRes = new DomainSelectRes();
                         int i = RandomUtil.randomInt(0, fm.size());
                         String domain = fm.get(i).domain();
@@ -382,14 +384,14 @@ public class PlanNewCommonOutController {
     private Mono<RStatus<DomainSelectRes>> getListeningPlan(OutDomainRequest request) {
         Mono<ListeningPlanNew> code1 = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), ListeningPlanNew.class)
                 .switchIfEmpty(Mono.error(new BaseException("计划code异常 返回结果为空")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException("计划code异常")));
         Mono<DomainSelectRes> domainSelectResMono1 = code1.flatMap(f -> template.select(Query.query(Criteria
                         .where("group_type_id").is(f.groupId())
                         .and("status").is(1)
                         .and("type").is(request.getType())
                         .and("deleted_at").isNull()), DomainSelect.class)
                 .switchIfEmpty(Mono.error(new BaseException("查询domain 返回结果为空")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList()
+                .onErrorResume(throwable -> Mono.error(new BaseException("查询domain 返回结果为空"))).collectList()
                 .flatMap(fm -> {
                     DomainSelectRes domainSelectRes = new DomainSelectRes();
                     int i = RandomUtil.randomInt(0, fm.size());
@@ -417,7 +419,7 @@ public class PlanNewCommonOutController {
                             .and("deleted_at").isNull()
                             .and("type").is(request.getType())), DomainSelect.class)
                     .switchIfEmpty(Mono.error(new BaseException("查询domain 返回结果为空")))
-                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
+                    .onErrorResume(throwable -> Mono.error(new BaseException("查询domain 返回结果为空")))
                     .collectList().flatMap(fm -> {
                         int i = RandomUtil.randomInt(0, fm.size());
                         String domain = fm.get(i).domain();
@@ -426,21 +428,21 @@ public class PlanNewCommonOutController {
                     });
         }
         Mono<String> transferPageDomain;
-        if ( Objects.nonNull(request.getTransferPageDomain()) && StringUtils.isNotEmpty(request.getTransferPageDomain())) {
+        if (Objects.nonNull(request.getTransferPageDomain()) && StringUtils.isNotEmpty(request.getTransferPageDomain())) {
             transferPageDomain = template.select(Query.query(Criteria
-                    .where("group_type_id").is(request.getTransferPageDomain())
-                    .and("status").is(1)
-                    .and("type").is(5)
-                    .and("deleted_at").isNull()), DomainSelect.class)
+                            .where("group_type_id").is(request.getTransferPageDomain())
+                            .and("status").is(1)
+                            .and("type").is(5)
+                            .and("deleted_at").isNull()), DomainSelect.class)
                     .switchIfEmpty(Mono.error(new BaseException("transferPageDomain 域名查詢為空 group_type_id:::" + request.getTransferPageDomain())))
-                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fff -> {
+                    .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()))).collectList().flatMap(fff -> {
                         if (!fff.isEmpty()) {
                             DomainSelect domainSelect = fff.get(RandomUtil.randomInt(0, fff.size()));
                             String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
                             String domain1 = domainSelect.domain();
                             return Mono.just(string + "." + domain1);
                         } else {
-                            throw new BaseException("transferPageDomain 中轉域名查詢為空 group_type_id:::" +  request.getTransferPageDomain());
+                            return Mono.error(new BaseException("transferPageDomain 中轉域名查詢為空 group_type_id:::" + request.getTransferPageDomain()));
                         }
                     });
         } else {
@@ -449,25 +451,25 @@ public class PlanNewCommonOutController {
         Mono<String> backgroupDomain;
         if (Objects.nonNull(request.getBackgroupDomain()) && StringUtils.isNotEmpty(request.getBackgroupDomain())) {
             backgroupDomain = template.select(Query.query(Criteria
-                    .where("group_type_id").is(request.getBackgroupDomain())
-                    .and("status").is(1)
-                    .and("type").is(4)
-                    .and("deleted_at").isNull()), DomainSelect.class)
+                            .where("group_type_id").is(request.getBackgroupDomain())
+                            .and("status").is(1)
+                            .and("type").is(4)
+                            .and("deleted_at").isNull()), DomainSelect.class)
                     .switchIfEmpty(Mono.error(new BaseException("backgroupDomain 域名查询为空 group_type_id" + request.getBackgroupDomain())))
-                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fff -> {
+                    .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()))).collectList().flatMap(fff -> {
                         if (!fff.isEmpty()) {
                             DomainSelect domainSelect = fff.get(RandomUtil.randomInt(0, fff.size()));
                             String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
                             String domain1 = domainSelect.domain();
                             return Mono.just(string + "." + domain1);
                         } else {
-                            throw new BaseException("backgroupDomain 背景域名查詢為空 group_type_id" + request.getBackgroupDomain());
+                            return Mono.error(new BaseException("backgroupDomain 背景域名查詢為空 group_type_id" + request.getBackgroupDomain()));
                         }
                     });
         } else {
             backgroupDomain = Mono.just(" ");
         }
-        Mono<DomainSelectRes> res = Mono.zip(stringMono,transferPageDomain,backgroupDomain).flatMap(tuple3 -> {
+        Mono<DomainSelectRes> res = Mono.zip(stringMono, transferPageDomain, backgroupDomain).flatMap(tuple3 -> {
             DomainSelectRes domainSelectRes = new DomainSelectRes();
             domainSelectRes.setDomain(tuple3.getT1());
             domainSelectRes.setTransferPageDomain(tuple3.getT2());
@@ -478,18 +480,19 @@ public class PlanNewCommonOutController {
         });
         return RStatus.success(res);
     }
+
     private Mono<RStatus<DomainSelectRes>> getTakeaway(OutDomainRequest request) {
         Mono<String> stringMono;
         if (StrUtil.isBlank(request.getLandingPageDomain()) || request.getLandingPageDomain().trim().isEmpty()) {
             stringMono = Mono.just(" ");
         } else {
             stringMono = template.select(Query.query(Criteria
-                    .where("group_type_id").is(request.getLandingPageDomain())
-                    .and("status").is(1)
-                    .and("deleted_at").isNull()
-                    .and("type").is(request.getType())), DomainSelect.class)
+                            .where("group_type_id").is(request.getLandingPageDomain())
+                            .and("status").is(1)
+                            .and("deleted_at").isNull()
+                            .and("type").is(request.getType())), DomainSelect.class)
                     .switchIfEmpty(Mono.error(new BaseException("查询domain 返回结果为空")))
-                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
+                    .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())))
                     .collectList().flatMap(fm -> {
                         int i = RandomUtil.randomInt(0, fm.size());
                         String domain = fm.get(i).domain();
@@ -517,7 +520,7 @@ public class PlanNewCommonOutController {
     public Mono<RStatus<PlanNewCommonMaterialRes>> getCommonMaterial(@RequestBody PlanNewCommonMaterialReq request) {
         Mono<PlanNewCommon> planNewCommonMono = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNewCommon.class)
                 .switchIfEmpty(Mono.error(new BaseException("计划code异常 返回结果为空")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException("计划code异常")));
         Mono<PlanNewCommonMaterialRes> materialResMono = planNewCommonMono.flatMap(plan -> {
             // 群音频
             Mono<Audio> groupAudio = this.getAudio(request.getAudioId());
@@ -531,7 +534,7 @@ public class PlanNewCommonOutController {
                 returnLoop = template.selectOne(Query.query(Criteria.where("id").is(request.getReturnLoopId())
                                 .and("deleted_at").isNull()), ReturnLoop.class)
                         .switchIfEmpty(Mono.just(getReturnLoop()))
-                        .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "3")));
+                        .onErrorResume(throwable -> Mono.error(new BaseException("查询返回广告异常")));
             }
             // 分享背景组
             Mono<List<BackgroupImageItem>> backgroupImageItemMono;
@@ -541,17 +544,17 @@ public class PlanNewCommonOutController {
                 backgroupImageItemMono = template.select(Query.query(Criteria
                                 .where("group_id").is(request.getBackgroundGroupId())), BackgroupImageItem.class).collectList()
                         .switchIfEmpty(Mono.just(List.of()))
-                        .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage() + "4")));
+                        .onErrorResume(throwable -> Mono.error(new BaseException("查询分享背景组异常")));
             }
-            Mono<TakeawayH5Data> takeaway ;
+            Mono<TakeawayH5Data> takeaway;
             if (Objects.nonNull(request.getTakeawayId()) && request.getTakeawayId() > 0) {
                 takeaway = takeawayServicesInterface.getTakeaway(request.getTakeawayId())
-                        .switchIfEmpty(Mono.error(new BaseException("查询外卖模版数据异常 查询结果为空")))
-                        .onErrorResume(e->Mono.error(new BaseException("查询外卖模版数据异常:::"+e.getMessage())));
-            }else {
-                takeaway=Mono.just(new TakeawayH5Data());
+                        .switchIfEmpty(Mono.just(new TakeawayH5Data()))
+                        .onErrorResume(e -> Mono.error(new BaseException("查询外卖模版数据异常:::" + e.getMessage())));
+            } else {
+                takeaway = Mono.just(new TakeawayH5Data());
             }
-            return Mono.zip(groupAudio, retAudio, returnLoop, backgroupImageItemMono,takeaway).flatMap(f -> {
+            return Mono.zip(groupAudio, retAudio, returnLoop, backgroupImageItemMono, takeaway).flatMap(f -> {
                 PlanNewCommonMaterialRes materialRes = new PlanNewCommonMaterialRes();
                 materialRes.setGroupAudio(f.getT1());
                 materialRes.setRetAudio(f.getT2());
@@ -606,17 +609,15 @@ public class PlanNewCommonOutController {
      */
     @PostMapping("planCommonShare")
     public Mono<RStatus<PlanNewCommonShareRes>> planCommonShare(@RequestBody PlanNewCommonShareReq request) {
-        if (MAP.containsKey(request.getUnique())) {
-            Integer integer = MAP.get(request.getUnique());
-            MAP.put(request.getUnique(), integer + 1);
-            request.setUserVisits(integer + 1);
-        } else {
-            MAP.put(request.getUnique(), 0);
-            request.setUserVisits(0);
+        if (request.getCode() == null || request.getCode().isEmpty()) {
+            throw new BaseException("code不能为空");
         }
         Mono<PlanNewCommon> planNewCommonMono = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNewCommon.class)
                 .switchIfEmpty(Mono.error(new BaseException(" code错误")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException(" code错误")));
+        // 记录访问
+        Integer visits = planServiceInterface.setUserVisitsToRedis(request.getUnique(), request.getCode());
+        request.setUserVisits(visits);
         Mono<PlanNewCommonShareRes> resMono = planNewCommonMono.flatMap(plan -> {
             Mono<StringBuilder> stringBuilderMono;
             boolean isQs = Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty();
@@ -627,7 +628,7 @@ public class PlanNewCommonOutController {
             if (Objects.nonNull(request.getRedirectType()) && request.getRedirectType() == 2) {
                 stringBuilderMono = goGenerateService.byPlanNewIdGetUrlCommon(request.getRedirectPlanId(), isQs, request.getGroupIdQs());
             } else {
-                stringBuilderMono = Mono.just(new StringBuilder(request.getLink()));
+                stringBuilderMono = Mono.just(new StringBuilder(request.getLink() == null ? "" : request.getLink()));
             }
             Mono<PlanNewCommon> code = Mono.just(plan);
             return Mono.zip(code, getPosterTemplate(code), getPoster(code), getPlanNewBackgroupPoster(code), getEwm(code), stringBuilderMono).flatMap(f -> {
@@ -656,7 +657,7 @@ public class PlanNewCommonOutController {
                             int v = userVisits % qs.size();
                             res.setQsSetting(qs.get(v));
                             if (f.getT6().toString().isEmpty()) {
-                                throw new BaseException("计划链接 查询匹配域名为空");
+                                return Mono.error(new BaseException("计划链接 查询匹配域名为空"));
                             }
                             res.setLink(f.getT6().toString());
                         } else {
@@ -678,7 +679,7 @@ public class PlanNewCommonOutController {
                             int v = userVisits % fx.size();
                             res.setFxSetting(fx.get(v));
                             if (f.getT6().toString().isEmpty()) {
-                                throw new BaseException("计划链接 查询匹配域名为空");
+                                return Mono.error(new BaseException("计划链接 查询匹配域名为空"));
                             }
                             res.setLink(f.getT6().toString());
                         } else {
@@ -736,21 +737,21 @@ public class PlanNewCommonOutController {
                  qrcodeInfoMono = template.insert(stringBuilder)
                         .onErrorResume(throwable -> Mono.error(new BaseException("插入QrcodeInfo异常::::" + throwable.getMessage())));
             }
-          return   Mono.zip(Mono.just(fm),qrcodeInfoMono).flatMap(fm1->{
-                if (Objects.nonNull(fm1.getT2().id())) {
-                    goRequest.getItem()
-                            .stream()
-                            .filter(filter -> "cusqrcode".equals(filter.getT())
-                                    && filter.getIsRandom()
-                                    && 1 == filter.getType()).collect(Collectors.toList()).forEach(fe -> {
-                        if (Objects.nonNull(fe.getV())) {
-                            if (fe.getV().contains("?")){
-                                String cusqrcode = fe.getV() + "&id=" + fm1.getT2().id();
-                                fe.setV(cusqrcode);
-                            }else{
-                                String cusqrcode = fe.getV() + "?id=" + fm1.getT2().id();
-                                fe.setV(cusqrcode);
-                            }
+            if (Objects.nonNull(ret)) {
+                JSONObject jsonObject1;
+                try {
+                    jsonObject1 = JSONUtil.parseObj(ret);
+                } catch (Exception e) {
+                    return Mono.error(new BaseException(e.getMessage() + "---" + JSONUtil.parseObj(goRequest) + " error:" + LogExceptionStackTrace.erroStackTrace(e).toString()));
+                }
+                if (jsonObject1.containsKey("code") && jsonObject1.get("code", Integer.class) == 0 && jsonObject1.containsKey("data")) {
+                    JSONObject data = jsonObject1.get("data", JSONObject.class);
+                    if (data.containsKey("Url")) {
+                        String url = data.get("Url", String.class);
+                        if (Objects.nonNull(request.getWx_user_id()) && !request.getWx_user_id().isEmpty() && 3 != fm.getPlanNew().type()) {
+                            fm.setQsGenerateImagesUrl(url);
+                        } else {
+                            fm.setFxGenerateImagesUrl(url);
                         }
                     });
                 }
@@ -835,7 +836,7 @@ public class PlanNewCommonOutController {
             try {
                 jsonObject = JSONUtil.parseObj(posterTemplate);
             } catch (Exception e) {
-                throw new BaseException(e.getMessage() + "---" + posterTemplate);
+                return Mono.error(new BaseException(e.getMessage() + "---" + posterTemplate + " error:" + LogExceptionStackTrace.erroStackTrace(e).toString()));
             }
             GoRequest goRequest = new GoRequest();
             BeanUtil.copyProperties(jsonObject, goRequest);

+ 8 - 8
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewController.java

@@ -141,7 +141,7 @@ public class PlanNewController {
     public Mono<RStatus<BackgroupImageRes>> backgroupImageRes(@PathVariable("id") Long id) {
         Mono<BackgroupImage> id1 = template.selectOne(Query.query(Criteria.where("id")
                         .is(id)), BackgroupImage.class).switchIfEmpty(Mono.error(new BaseException(" 通过code查询结果为空")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())));
         Mono<List<BackgroupImageItem>> group_id = template.select(Query.query(Criteria.where("group_id")
                 .is(id)).sort(Sort.by(Sort.Order.asc("index"))), BackgroupImageItem.class).collectList();
         Mono<BackgroupImageRes> zip = Mono.zip(id1, group_id, (lambdaA, lambdaB) -> {
@@ -386,7 +386,7 @@ public class PlanNewController {
     @PostMapping("posterTemList")
     public Mono<RStatus<Paged<PosterTemplateRes>>> posterTemList(@RequestBody PosterTemPage request) {
         Criteria criteria = Criteria.empty(); // poster_template_id
-        if (Objects.nonNull(request.getName()) && "" != request.getName()) {
+        if (Objects.nonNull(request.getName()) && "" != request.getName().trim()) {
             criteria = criteria.and("name").is(request.getName());
         }
         Query query = Query.query(criteria);
@@ -792,7 +792,7 @@ public class PlanNewController {
             Query plan_new_id2 = Query.query(Criteria.where("plan_new_id").is(planNewId));
             Mono<Long> plan_new_id = template.delete(plan_new_id2, PlanNew.class)
                     .switchIfEmpty(Mono.error(new BaseException("计划id异常"))) // Mono.error(new BaseException("查询海报模版 id:"+f.posterTemplateId()+"=>空"))
-                    .onErrorResume(throwable -> Mono.error(new Exception("删除计划 " + planNewId + "---" + type + "error:" + throwable.getMessage())));
+                    .onErrorResume(throwable -> Mono.error(new BaseException("删除计划 " + planNewId + "---" + type + "error:" + throwable.getMessage())));
             Mono<Long> plan_new_id1 = template.count(plan_new_id2, PlanNewBackgroupPoster.class).filter(f -> f > 0)
                     .flatMap(f -> template.delete(plan_new_id2, PlanNewBackgroupPoster.class))
                     .switchIfEmpty(Mono.just(0L));
@@ -803,7 +803,7 @@ public class PlanNewController {
                     .is(planNewId));
             Mono<Long> listening_plan_new_id = template.delete(listening_plan_new_id1, ListeningPlanNew.class)
                     .switchIfEmpty(Mono.error(new BaseException("计划id异常"))) // Mono.error(new BaseException("查询海报模版 id:"+f.posterTemplateId()+"=>空"))
-                    .onErrorResume(throwable -> Mono.error(new Exception("删除计划 " + planNewId + "---" + type + "error:" + throwable.getMessage())));
+                    .onErrorResume(throwable -> Mono.error(new BaseException("删除计划 " + planNewId + "---" + type + "error:" + throwable.getMessage())));
             Mono<Long> plan_new_id1 = template.count(listening_plan_new_id1, ListeningPlanNewBackgroupPoster.class).filter(f -> f > 0)
                     .flatMap(f -> template.delete(listening_plan_new_id1, ListeningPlanNewBackgroupPoster.class))
                     .switchIfEmpty(Mono.just(0L));
@@ -874,7 +874,7 @@ public class PlanNewController {
                                 return Mono.just(planNewAllRs);
                             }
                     ).switchIfEmpty(Mono.error(new BaseException("计划id异常"))) // Mono.error(new BaseException("查询海报模版 id:"+f.posterTemplateId()+"=>空"))
-                    .onErrorResume(throwable -> Mono.error(new Exception("计划id异常")));
+                    .onErrorResume(throwable -> Mono.error(new BaseException("计划id异常")));
             return RStatus.success(planNewAllRsMono);
         } else if (2 == type) {
             Mono<PlanNewAllRs> planNewAllRsMono = template
@@ -926,7 +926,7 @@ public class PlanNewController {
                                 return Mono.just(planNewAllRs);
                             }
                     ).switchIfEmpty(Mono.error(new BaseException("计划id异常"))) // Mono.error(new BaseException("查询海报模版 id:"+f.posterTemplateId()+"=>空"))
-                    .onErrorResume(throwable -> Mono.error(new Exception("计划id异常")));
+                    .onErrorResume(throwable -> Mono.error(new BaseException("计划id异常")));
             return RStatus.success(planNewAllRsMono);
         }
         throw new BaseException("type类型错误");
@@ -1053,11 +1053,11 @@ public class PlanNewController {
             Mono<String> poster_template_id = template.selectOne(Query.query(Criteria.where("poster_template_id")
                             .is(f.posterTemplateId())), PosterTemplate.class).flatMap(f0 -> Mono.just(f0.posterTemplateName()))
                     .switchIfEmpty(Mono.just("")) // Mono.error(new BaseException("查询海报模版 id:"+f.posterTemplateId()+"=>空"))
-                    .onErrorResume(throwable -> Mono.error(new Exception("查询海报模版 id:" + f.posterTemplateId() + "error:" + throwable.getMessage())));
+                    .onErrorResume(throwable -> Mono.error(new BaseException("查询海报模版 id:" + f.posterTemplateId() + "error:" + throwable.getMessage())));
             Mono<String> id = template.selectOne(Query.query(Criteria.where("id").is(f.groupId())), GroupType.class)
                     .flatMap(f1 -> Mono.just(f1.name()))
                     .switchIfEmpty(Mono.just(""))// Mono.error(new BaseException("查询GroupType id:"+f.groupId()+"=>空"))
-                    .onErrorResume(throwable -> Mono.error(new Exception("查询GroupType id:" + f.groupId() + "error:" + throwable.getMessage())));
+                    .onErrorResume(throwable -> Mono.error(new BaseException("查询GroupType id:" + f.groupId() + "error:" + throwable.getMessage())));
             return Mono.zip(Mono.just(f), poster_template_id, id).flatMap(ff -> {
                 PlanNew t1 = ff.getT1();
                 ListeningPlanNewRes2 listeningPlanNewRes = new ListeningPlanNewRes2();

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

@@ -13,6 +13,7 @@ import com.webflux.launchadmin.mysql.controller.planNew.req.*;
 import com.webflux.launchadmin.mysql.controller.planNew.res.*;
 import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
 import com.webflux.launchadmin.mysql.entity.planNew.*;
+import com.webflux.launchadmin.mysql.service.planNew.PlanServiceInterface;
 import com.webflux.launchadmin.mysql.service.planNew.goGenerate.GoGenerateService;
 import com.webflux.launchadmin.mysql.service.planNew.ipAnalyze.IpAnalyzeServiceInterface;
 import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
@@ -60,17 +61,22 @@ public class PlanNewOutController {
     @Resource
     private IpAnalyzeServiceInterface ipAnalyzeServiceInterface;
 
+    @Autowired
+    private StringRedisTemplate stringRedisTemplate;
 
+    @Resource
+    private PlanServiceInterface planServiceInterface;
 
     private static final ConcurrentHashMap<String,Integer> map = new ConcurrentHashMap<String,Integer>();
 
     //清空用户Map数据
-    @Scheduled(cron="1 1 4 * * ?")
-    public void clearUserContextMap(){
-        log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》开始");
-        map.clear();
-        log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》 结束");
-    }
+    // @Scheduled(cron="1 1 4 * * ?")
+    // @SchedulerLock(name = "launch:PlanNewOutController:clearUserContextMap", lockAtLeastFor = "PT5S", lockAtMostFor = "PT15M")
+    // public void clearUserContextMap(){
+    //     log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》开始");
+    //     map.clear();
+    //     log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》 结束");
+    // }
 
     /**
      * 获取二维码缓存信息
@@ -96,7 +102,7 @@ public class PlanNewOutController {
             Mono<PlanNew> code1 = template
                     .selectOne(Query.query(Criteria.where("code").is(code)), PlanNew.class)
                     .switchIfEmpty(Mono.error(new BaseException("计划code异常 返回结果为空"))) //Mono.error(new BaseException("查询海报模版 id:"+f.posterTemplateId()+"=>空"))
-                    .onErrorResume(throwable -> Mono.error(new Exception(  throwable.getMessage())));
+                    .onErrorResume(throwable -> Mono.error(new BaseException(  throwable.getMessage())));
             Mono<DomainSelectRes> domainSelectResMono1 = code1.flatMap(f -> {
                 Mono<String> stringMono;
                 if (f.transferPageBl() == 1 && Objects.nonNull(f.transferPageDomain())) {
@@ -106,7 +112,7 @@ public class PlanNewOutController {
                             .and("type").is(5)
                             .and("deleted_at").isNull()), DomainSelect.class)
                             .switchIfEmpty(Mono.error(new BaseException("transferPageDomain 域名查詢為空 group_type_id:::" + f.transferPageDomain())))
-                            .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fff -> {
+                            .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()))).collectList().flatMap(fff -> {
                                 if (!fff.isEmpty()) {
                                     DomainSelect domainSelect = fff.get(RandomUtil.randomInt(0, fff.size()));
                                     String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
@@ -128,7 +134,7 @@ public class PlanNewOutController {
                             .and("type").is(4)
                             .and("deleted_at").isNull()), DomainSelect.class)
                             .switchIfEmpty(Mono.error(new BaseException("backgroupDomain 域名查詢為空 group_type_id" + f.backgroupDomain())))
-                            .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fff -> {
+                            .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()))).collectList().flatMap(fff -> {
                                 if (!fff.isEmpty()) {
                                     DomainSelect domainSelect = fff.get(RandomUtil.randomInt(0, fff.size()));
                                     String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
@@ -144,7 +150,7 @@ public class PlanNewOutController {
                 Mono<String> stringMono2 = template.select(Query.query(Criteria.where("group_type_id").is(f.landingPageDomain())
                         .and("status").is(1).and("type").is(type).and("deleted_at").isNull()), DomainSelect.class)
                         .switchIfEmpty(Mono.error(new BaseException("查询domain 返回结果为空")))
-                        .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fm -> {
+                        .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()))).collectList().flatMap(fm -> {
                           //  DomainSelectRes domainSelectRes = new DomainSelectRes();
                             int i = RandomUtil.randomInt(0, fm.size());
                             String domain = fm.get(i).domain();
@@ -170,23 +176,31 @@ public class PlanNewOutController {
             });
             return RStatus.success(domainSelectResMono1);
         }else  if(2==typePlan){
-            Mono<ListeningPlanNew> code1 = template.selectOne(Query.query(Criteria.where("code").is(code)), ListeningPlanNew.class)
-                    .switchIfEmpty(Mono.error(new BaseException("计划code异常 返回结果为空"))) //Mono.error(new BaseException("查询海报模版 id:"+f.posterTemplateId()+"=>空"))
-                    .onErrorResume(throwable -> Mono.error(new Exception(  throwable.getMessage())));
-            Mono<DomainSelectRes> domainSelectResMono1 = code1.flatMap(f -> template.select(Query.query(Criteria.where("group_type_id").is(f.groupId())
-                    .and("status").is(1).and("type").is(type).and("deleted_at").isNull()), DomainSelect.class)
-                    .switchIfEmpty(Mono.error(new BaseException("查询domain 返回结果为空")))
-                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fm -> {
-                        DomainSelectRes domainSelectRes = new DomainSelectRes();
-                        int i = RandomUtil.randomInt(0, fm.size());
-                        String domain = fm.get(i).domain();
-                        String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
-                        domainSelectRes.setDomain(string+"."+domain);
-                        domainSelectRes.setPath("");
-                        domainSelectRes.setUnique(IdUtil.fastSimpleUUID());
-                        return Mono.just(domainSelectRes);
-                    }));
-            return RStatus.success(domainSelectResMono1);
+            Long start = System.currentTimeMillis();
+            Object planCache = stringRedisTemplate.opsForHash().get(RedisKey.PLAN_LISTEN_INFO,code);
+            if (planCache == null){
+                throw new BaseException("未获取到计划信息");
+            }
+            ListeningPlanNew planInfo = com.alibaba.fastjson.JSONObject.parseObject(planCache.toString(),ListeningPlanNew.class);
+            String idKey = RedisKey.DOMAIN_RAND_ID + planInfo.groupId().toString() + ":" + type.toString();
+            String domainId = stringRedisTemplate.opsForSet().randomMember(idKey);
+            if (domainId.isEmpty()){
+                throw new BaseException("缓存"+ idKey + "不存在");
+            }
+            Object domainInfoCache = stringRedisTemplate.opsForHash().get(RedisKey.DOMAIN_INFO,domainId);
+            if (domainInfoCache == null){
+                throw new BaseException("缓存" + RedisKey.DOMAIN_INFO + "指定域名信息不存在");
+            }
+            DomainSelect domainInfo = com.alibaba.fastjson.JSONObject.parseObject(domainInfoCache.toString(),DomainSelect.class);
+            DomainSelectRes domainSelectRes = new DomainSelectRes();
+            String domain = domainInfo.domain();
+            String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
+            domainSelectRes.setDomain(string+"."+domain);
+            domainSelectRes.setPath("");
+            domainSelectRes.setUnique(IdUtil.fastSimpleUUID());
+            Long end = System.currentTimeMillis();
+            log.info("volta-time:{}-{}-{}",start,end,start-end);
+            return RStatus.success(Mono.just(domainSelectRes));
         }
         throw new BaseException("typePlan 类型错误");
 
@@ -202,7 +216,7 @@ public class PlanNewOutController {
     public Mono<RStatus<DataListsKefu>> kefuList(@RequestBody KefuRequest request){
         Mono<PlanNew> code = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNew.class)
                 .switchIfEmpty(Mono.error(new BaseException("code查询返回结构为空"))) //Mono.error(new BaseException("查询海报模版 id:"+f.posterTemplateId()+"=>空"))
-                .onErrorResume(throwable -> Mono.error(new Exception("通过code查询计划异常::" + throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException("通过code查询计划异常::" + throwable.getMessage())));
         Mono<DataListsKefu> dataListsKefuMono = code.flatMap(planNew -> {
             Mono<List<Image>> image = template.select(Query.query(Criteria.where("type").is(5)
                     .and("deleted_at").isNull()
@@ -210,13 +224,13 @@ public class PlanNewOutController {
                     .collectList()
                     .switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Image返回结构为空", planNew.groupId()))))
                     .onErrorResume(throwable ->
-                            Mono.error(new Exception(StrUtil.format("通过计划groupId:{}查询Image返回结果error:{}", planNew.groupId(), throwable.getMessage()))));
+                            Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Image返回结果error:{}", planNew.groupId(), throwable.getMessage()))));
             Mono<List<Material>> text = template.select(Query.query(Criteria.where("type").is(11)
                             .and("group_type_id").is(planNew.groupId())
                             .and("deleted_at").isNull()), Material.class)
                     .switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Material返回结构为空", planNew.groupId()))))
                     .onErrorResume(throwable ->
-                            Mono.error(new Exception(StrUtil.format("通过计划groupId:{}查询Material返回结果error:{}", planNew.groupId(), throwable.getMessage()))))
+                            Mono.error(new BaseException(StrUtil.format("通过计划groupId:{}查询Material返回结果error:{}", planNew.groupId(), throwable.getMessage()))))
                     .collectList();
             Mono<List<H5ImageAndText>> arrayListMono = Mono.zip(Mono.just(planNew), image, text).flatMap(f -> {
                 //H5ImageAndText
@@ -300,6 +314,9 @@ public class PlanNewOutController {
      */
     @PostMapping("hfoInfo")
     public Mono<RStatus<DataLists>> hfoInfo(@RequestBody HfoRequest request, ServerWebExchange exchange){
+        if (Objects.isNull(request.getCode()) || "".equals(request.getCode().trim())) {
+          throw  new BaseException("code异常");
+        }
         ServerHttpRequest httpRequest = exchange.getRequest();
         InetSocketAddress remoteAddress = httpRequest.getRemoteAddress();
         String ipAddress;
@@ -311,7 +328,7 @@ public class PlanNewOutController {
 
         Mono<PlanNew> code0 = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNew.class)
                 .switchIfEmpty(Mono.error(new BaseException(" code错误")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())));
         Mono<DataLists> dataListsMono1 = code0.flatMap(planNew -> {
             Mono<PlanNew> code = Mono.just(planNew);
             Long group_type_id ; //.and("group_type_id").is(group_type_id)
@@ -321,7 +338,7 @@ public class PlanNewOutController {
                 group_type_id=planNew.groupIdQs();
             }
             Mono<List<Domain>> domain = code.flatMap(plan -> template.select(Query.query(Criteria.where("group_type").is(1)
-                    .and("deleted_at").isNull()), Domain.class).onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()+"6"))).collectList());
+                    .and("deleted_at").isNull()), Domain.class).onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"6"))).collectList());
             // //类型 1素材分类2清水分类
             Criteria criteria = Criteria.where("type")
                     .is(1).and("deleted_at").isNull()
@@ -333,11 +350,11 @@ public class PlanNewOutController {
             }
             Query query = Query.query(criteria);
             Mono<List<Image>> image = template.select(query, Image.class)
-                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()+"7")))
+                    .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"7")))
                     .collectList();
             Mono<List<Material>> text = template.select(Query.query(Criteria.where("type")
                     .is(4).and("deleted_at").isNull().and("group_type_id").is(group_type_id)), Material.class)
-                    .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()+"8")))
+                    .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"8")))
                     .collectList();
             Mono<UserVisits> wx_user_id ;
             if (Objects.isNull(request.getWx_user_id()) || "".equals(request.getWx_user_id())) {
@@ -345,13 +362,13 @@ public class PlanNewOutController {
             }else{
                 Mono<UserVisits> insert = template.insert(new UserVisits(null, request.getWx_user_id(), 1));
                  wx_user_id = template.selectOne(Query.query(Criteria.where("wx_user_id").is(request.getWx_user_id())), UserVisits.class)
-                         .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()+"9")))
+                         .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"9")))
                         .flatMap(f -> {
                             if (f.num() >= 4) {
                                 return Mono.just(f);
                             } else {
                                 return template.update(new UserVisits(f.id(), f.wxUserId(), f.num() + 1))
-                                        .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()+"10")));
+                                        .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"10")));
                             }
                         }).switchIfEmpty(insert);
             }
@@ -414,18 +431,18 @@ public class PlanNewOutController {
                             Query.query(Criteria.where("id").is(plan.listAudioId()).and("deleted_at").isNull()),
                             Audio.class);
                 } }
-            ).onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()+"1")));
+            ).onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"1")));
             Mono<Audio> retAudioId = code.flatMap(plan -> template.selectOne(Query.query(Criteria.where("id")
-                    .is(plan.retAudioId()).and("deleted_at").isNull()), Audio.class)).onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()+"2")));
+                    .is(plan.retAudioId()).and("deleted_at").isNull()), Audio.class)).onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"2")));
             Mono<ReturnLoop> returnLoop = code.flatMap(plan -> {
                 if (Objects.isNull(plan.returnLoopId())) {
                     return Mono.just(getReturnLoop());
                 } else {
-                    return template.selectOne(Query.query(Criteria.where("id").is(plan.returnLoopId()).and("deleted_at").isNull()), ReturnLoop.class).onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()+"3")));
+                    return template.selectOne(Query.query(Criteria.where("id").is(plan.returnLoopId()).and("deleted_at").isNull()), ReturnLoop.class).onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"3")));
                 }
             }).switchIfEmpty(Mono.just(getReturnLoop()));
-            Mono<List<Ad>> adtop = template.select(Query.query(Criteria.where("type").is(1).and("deleted_at").isNull()), Ad.class).onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()+"4"))).collectList();////广告类型1顶部2底部3返回4安卓,ios的返回
-            Mono<List<Ad>> bottom = template.select(Query.query(Criteria.where("type").is(2).and("deleted_at").isNull()), Ad.class).onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()+"5"))).collectList();
+            Mono<List<Ad>> adtop = template.select(Query.query(Criteria.where("type").is(1).and("deleted_at").isNull()), Ad.class).onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"4"))).collectList();////广告类型1顶部2底部3返回4安卓,ios的返回
+            Mono<List<Ad>> bottom = template.select(Query.query(Criteria.where("type").is(2).and("deleted_at").isNull()), Ad.class).onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"5"))).collectList();
 
 
             Mono<DataLists> dataListsMono = Mono.zip(code, listAudio, retAudioId, returnLoop, arrayListMono, adtop, bottom, wx_user_id).flatMap(f -> {
@@ -529,17 +546,15 @@ public class PlanNewOutController {
      */
     @PostMapping("hftInfo")
     public Mono<RStatus<DataLists0>> hftInfo(@RequestBody HftRequest request){
-        if(map.containsKey(request.getUnique())){
-            Integer integer = map.get(request.getUnique());
-            map.put(request.getUnique(),integer+1);
-            request.setUserVisits(integer+1);
-        }else {
-            map.put(request.getUnique(),0);
-            request.setUserVisits(0);
+        if (request.getCode() == null || request.getCode().isEmpty()) {
+            throw new BaseException("code不能为空");
         }
         Mono<PlanNew> code0 = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNew.class)
                 .switchIfEmpty(Mono.error(new BaseException(" code错误")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())));
+        // 获取用户访问次数
+        Integer visits = planServiceInterface.setUserVisitsToRedis(request.getUnique(), request.getCode());
+        request.setUserVisits(visits);
         Mono<DataLists0> dataLists0Mono =  code0.flatMap(ftmp->{
             //(如果wx_user_id值不为空则使用清水分类)
             Mono<StringBuilder> stringBuilderMono;
@@ -678,6 +693,7 @@ public class PlanNewOutController {
                     try {
                         jsonObject1 =  JSONUtil.parseObj(ret);
                     }catch (Exception e){
+                        log.error(e.getMessage() +"---"+JSONUtil.parseObj(goRequest2), e);
                         throw new BaseException(e.getMessage() +"---"+JSONUtil.parseObj(goRequest2));
                     }
                     if (jsonObject1.containsKey("code")
@@ -717,6 +733,7 @@ public class PlanNewOutController {
             try {
                 jsonObject = JSONUtil.parseObj(posterTemplate);
             }catch (Exception e){
+                log.error(e.getMessage() +"---"+posterTemplate, e);
                 throw new BaseException(e.getMessage() +"---"+posterTemplate);
             }
             //JSONObject jsonObject = JSONUtil.parseObj(posterTemplate);
@@ -818,6 +835,7 @@ public class PlanNewOutController {
             try {
                 encodedParam = URLEncoder.encode(first3.get().getV(), StandardCharsets.UTF_8.toString());
             }catch (Exception e){
+                log.error("URLEncoder Error"+e.getMessage(), e);
                 throw new BaseException("URLEncoder Error"+e.getMessage());
             }
         }
@@ -830,6 +848,7 @@ public class PlanNewOutController {
         try {
              jsonObject =  JSONUtil.parseObj(posterTemplate);
         }catch (Exception e){
+            log.error(e.getMessage() +"---"+posterTemplate, e);
             throw new BaseException(e.getMessage() +"---"+posterTemplate);
         }
         //JSONObject jsonObject = JSONUtil.parseObj(posterTemplate);

+ 23 - 18
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/listening/ListeningPlanServiceImpl.java

@@ -20,6 +20,7 @@ import com.webflux.launchadmin.mysql.entity.listening.ListeningAudio;
 import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
 import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNewBackgroupPoster;
 import com.webflux.launchadmin.mysql.entity.planNew.*;
+import com.webflux.launchadmin.mysql.service.planNew.PlanServiceInterface;
 import com.webflux.launchadmin.mysql.service.planNew.goGenerate.GoGenerateService;
 import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
 import com.webflux.launchadmin.mysql.service.planNew.structure.Item;
@@ -51,6 +52,8 @@ public class ListeningPlanServiceImpl implements ListeningPlanServiceInterface{
     private GoGenerateService goGenerateService;
     @Resource
     private R2dbcEntityTemplate template;
+    @Resource
+    private PlanServiceInterface planServiceInterface;
     @Override
     public Mono<RStatus<Paged<ListeningPlanNewRes2>>> page(PlanReqPage request, Criteria criteria) {
         Query query = Query.query(criteria);
@@ -63,11 +66,11 @@ public class ListeningPlanServiceImpl implements ListeningPlanServiceInterface{
             Mono<String> poster_template_id = template.selectOne(Query.query(Criteria.where("poster_template_id")
                     .is(f.posterTemplateId())), PosterTemplate.class).flatMap(f0 -> Mono.just(f0.posterTemplateName()))
                     .switchIfEmpty(Mono.just("")) //Mono.error(new BaseException("查询海报模版 id:"+f.posterTemplateId()+"=>空"))
-                    .onErrorResume(throwable -> Mono.error(new Exception("查询海报模版 id:" + f.posterTemplateId() + "error:" + throwable.getMessage())));
+                    .onErrorResume(throwable -> Mono.error(new BaseException("查询海报模版 id:" + f.posterTemplateId() + "error:" + throwable.getMessage())));
             Mono<String> id = template.selectOne(Query.query(Criteria.where("id").is(f.groupId())), GroupType.class)
                     .flatMap(f1 -> Mono.just(f1.name()))
                     .switchIfEmpty(Mono.just(""))//Mono.error(new BaseException("查询GroupType id:"+f.groupId()+"=>空"))
-                    .onErrorResume(throwable -> Mono.error(new Exception("查询GroupType id:" + f.groupId() + "error:" + throwable.getMessage())));
+                    .onErrorResume(throwable -> Mono.error(new BaseException("查询GroupType id:" + f.groupId() + "error:" + throwable.getMessage())));
             return Mono.zip(Mono.just(f), poster_template_id, id).flatMap(ff -> {
                 ListeningPlanNew t1 = ff.getT1();
                 ListeningPlanNewRes2 listeningPlanNewRes = new ListeningPlanNewRes2();
@@ -313,7 +316,7 @@ public class ListeningPlanServiceImpl implements ListeningPlanServiceInterface{
         Mono<ListeningPlanNew> listening_plan_new_id = template
                 .selectOne(Query.query(Criteria.where("listening_plan_new_id").is(listeningPlanNewId)), ListeningPlanNew.class)
                 .switchIfEmpty(Mono.error(new BaseException("计划错误")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
+                .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())))
                 .flatMap(f -> {
                     ListeningPlanNew listeningPlanNew = new ListeningPlanNew(IdUtil.fastSimpleUUID(),
                             f.name(),
@@ -382,7 +385,7 @@ public class ListeningPlanServiceImpl implements ListeningPlanServiceInterface{
         Mono<ListeningPlanNew> code1 = template.selectOne(Query.query(Criteria.where("code")
                 .is(outListeningRequest.getCode())), ListeningPlanNew.class)
                 .switchIfEmpty(Mono.error(new BaseException(" code错误")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())));
         Mono<ListeningDataLists> idx_num1 = code1.flatMap(f -> {
             Mono<List<ListeningAudio>> idx_num = template.select(Query.query(Criteria.empty())
                     .sort(Sort.by(Sort.Order.asc("idx_num")))
@@ -414,26 +417,25 @@ public class ListeningPlanServiceImpl implements ListeningPlanServiceInterface{
     }
     private static final ConcurrentHashMap<String,Integer> map = new ConcurrentHashMap<>();
     //清空用户Map数据
-    @Scheduled(cron="1 2 4 * * ?")
-    public void clearUserContextMap(){
-        log.info("清空听书裂变计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》开始");
-        map.clear();
-        log.info("空听书裂变计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》 结束");
-    }
+    // @Scheduled(cron="1 2 4 * * ?")
+    // @SchedulerLock(name = "launch:ListeningPlanServiceImpl:clearUserContextMap", lockAtLeastFor = "PT5S", lockAtMostFor = "PT15M")
+    // public void clearUserContextMap(){
+    //     log.info("清空听书裂变计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》开始");
+    //     map.clear();
+    //     log.info("空听书裂变计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》 结束");
+    // }
     @Override
     public Mono<RStatus<DataListsShare>> share(OutListeningShareRequest request) {
-        if(map.containsKey(request.getUnique())){
-            Integer integer = map.get(request.getUnique());
-            map.put(request.getUnique(),integer+1);
-            request.setUserVisits(integer+1);
-        }else {
-            map.put(request.getUnique(),0);
-            request.setUserVisits(0);
+        if (request.getCode() == null || request.getCode().isEmpty()) {
+            throw new BaseException("code不能为空");
         }
         Mono<ListeningPlanNew> code1 = template.selectOne(Query.query(Criteria.where("code")
                 .is(request.getCode())), ListeningPlanNew.class)
                 .switchIfEmpty(Mono.error(new BaseException("hello!!! code错误")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
+                .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())));
+        // 获取用户访问次数
+        Integer visits = planServiceInterface.setUserVisitsToRedis(request.getUnique(), request.getCode());
+        request.setUserVisits(visits);
         Mono<DataListsShare> dataListsShareMono = code1.flatMap(ftmp -> {
             Mono<ListeningPlanNew> code = Mono.just(ftmp);
             return Mono.zip(code, getPoster_template_id(code), getPoster(code), getPlanNewBackgroupPoster(code), getQrcode(code)).flatMap(f -> {
@@ -469,6 +471,7 @@ public class ListeningPlanServiceImpl implements ListeningPlanServiceInterface{
                 try {
                     jsonObject = JSONUtil.parseObj(posterTemplate);
                 } catch (Exception e) {
+                    log.error(e.getMessage() + "--解析海报模版--Errrrrrrrr" + posterTemplate, e);
                     throw new BaseException(e.getMessage() + "--解析海报模版--Errrrrrrrr" + posterTemplate);
                 }
                 GoRequest goRequest = new GoRequest();
@@ -743,6 +746,7 @@ public class ListeningPlanServiceImpl implements ListeningPlanServiceInterface{
                 try {
                     jsonObject1 =  JSONUtil.parseObj(ret);
                 }catch (Exception e){
+                    log.error(e.getMessage() +"--解析错误结果--"+JSONUtil.parseObj(goRequest), e);
                     throw new BaseException(e.getMessage() +"--解析错误结果--"+JSONUtil.parseObj(goRequest));
                 }
                 if (jsonObject1.containsKey("code") && jsonObject1.get("code", Integer.class) == 0 && jsonObject1.containsKey("data")) {
@@ -1099,6 +1103,7 @@ public class ListeningPlanServiceImpl implements ListeningPlanServiceInterface{
             body = HttpUtil.post(value + "/api/image/createImage",temStr,100000);
             return body;
         } catch (Exception e) {
+            log.error(e.getMessage() + "body:::" +body, e);
             throw new BaseException(e.getMessage() + "body:::" +body);
         }
 

+ 29 - 2
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/planNew/PlanServiceImpl.java

@@ -9,19 +9,26 @@ import com.webflux.launchadmin.mysql.entity.planNew.PlanNewCommon;
 import com.webflux.launchadmin.mysql.entity.planNew.PosterTemplate;
 import com.webflux.launchcommon.returnObj.Paged;
 import com.webflux.launchcommon.returnObj.RStatus;
+import com.weblux.launchredis.utils.RedisKey;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.data.relational.core.query.Criteria;
 import org.springframework.data.relational.core.query.Query;
 import org.springframework.stereotype.Service;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
+import java.time.Duration;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.util.Comparator;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
@@ -35,12 +42,14 @@ public class PlanServiceImpl implements PlanServiceInterface {
 
     @Resource
     private R2dbcEntityTemplate template;
+    @Resource
+    private StringRedisTemplate stringRedisTemplate;
 
     @Override
     public Mono<RStatus<Paged<ListeningPlanNewRes2>>> page(PlanReqPage request, Criteria criteria) {
         Query query = Query.query(criteria);
-        int skip  = (request.getPage() - 1) * request.getSize();
-        int limit =  request.getSize();
+        int skip = (request.getPage() - 1) * request.getSize();
+        int limit = request.getSize();
         Mono<Long> count = template.count(query, PlanNewCommon.class);
         Flux<PlanNewCommon> createdAt = template.select(Query.query(criteria)
                 .offset(skip)
@@ -79,4 +88,22 @@ public class PlanServiceImpl implements PlanServiceInterface {
         return RStatus.successList(pagedMono);
     }
 
+    @Override
+    public Integer setUserVisitsToRedis(String unique, String code) {
+        String redisKey = RedisKey.H5_USER_UNIQUE + unique;
+        int integer = 0;
+        if (Boolean.TRUE.equals(stringRedisTemplate.hasKey(redisKey))) {
+            Object val = stringRedisTemplate.opsForHash().get(redisKey, code);
+            if (val != null) {
+                integer = Integer.parseInt(val.toString());
+                integer = integer + 1;
+            }
+        }
+        stringRedisTemplate.opsForHash().put(redisKey, code, Integer.toString(integer));
+        // 设置过期时间
+        LocalDateTime expireTime = LocalDateTime.of(LocalDate.now().plusDays(1), LocalTime.of(4, 0));
+        long minute = Duration.between(LocalDateTime.now(), expireTime).toMinutes();
+        stringRedisTemplate.expire(redisKey, minute, TimeUnit.MINUTES);
+        return integer;
+    }
 }

+ 1 - 0
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/planNew/PlanServiceInterface.java

@@ -13,4 +13,5 @@ import reactor.core.publisher.Mono;
 public interface PlanServiceInterface {
     Mono<RStatus<Paged<ListeningPlanNewRes2>>> page(PlanReqPage request, Criteria criteria);
 
+    Integer setUserVisitsToRedis(String unique, String code);
 }

+ 23 - 18
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/planNew/goGenerate/GoGenerateService.java

@@ -22,6 +22,7 @@ import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
 import com.webflux.launchadmin.mysql.service.planNew.structure.Item;
 import com.webflux.launchcommon.returnObj.RStatus;
 import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
 import org.springframework.data.relational.core.query.Criteria;
@@ -42,7 +43,7 @@ import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-
+@Slf4j
 @Service
 public class GoGenerateService {
 
@@ -56,21 +57,25 @@ public class GoGenerateService {
     // http://wx-share-8.duiweize.com 正式
     public String goGenerate(String temStr) {
         String body = "";
+        String url = value + "/api/image/createImage";
         try {
-            body = HttpUtil.post(value + "/api/image/createImage", temStr, 100000);
+            body = HttpUtil.post(url, temStr, 100000);
             return body;
         } catch (Exception e) {
+            log.error("error: body:::" + body + ":::request:::" + temStr + ", url: {}", url, e);
             throw new BaseException(e.getMessage() + "body:::" + body + ":::request:::" + temStr);
         }
     }
 
     public String goGenerateStr(String temStr) {
         String body = "";
+        String url = value + "/api/image/createImage";
         try {
-            body = HttpUtil.post(value + "/api/image/createImage", temStr, 100000);
+            body = HttpUtil.post(url, temStr, 100000);
             JSONUtil.parseObj(body);
             return body;
         } catch (Exception e) {
+            log.error("error: body:::" + body + ":::request:::" + temStr + ", url: {}", url, e);
             throw new BaseException(e.getMessage() + "body:::" + body);
         }
 
@@ -116,7 +121,7 @@ public class GoGenerateService {
                         getImageType1Poster(imageGroupId2),
                         getTextListsTitleSaveOrUpdatePoster(posterRequset)))
                 .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
+                .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())))
                 .flatMap(f -> template.insert(f));
         return RStatus.success(posterMono1);
     }
@@ -142,7 +147,7 @@ public class GoGenerateService {
                         .and("group_type_id").is(groupTypeId)
                         .and("size_type").is(1)
                         .and("deleted_at").isNull()), Image.class)
-                .onErrorResume(throwable -> Mono.error(new Exception("getImageType1Plan error:" + throwable.getMessage())))
+                .onErrorResume(throwable -> Mono.error(new BaseException("getImageType1Plan error:" + throwable.getMessage())))
                 .collectList();
     }
 
@@ -162,7 +167,7 @@ public class GoGenerateService {
         return template.select(Query.query(Criteria.where("type").is(14)
                         .and("group_type_id").in(groupTypeId)
                         .and("deleted_at").isNull()), Material.class)
-                .onErrorResume(throwable -> Mono.error(new Exception("getTextListsPlan error:" + throwable.getMessage())))
+                .onErrorResume(throwable -> Mono.error(new BaseException("getTextListsPlan error:" + throwable.getMessage())))
                 .collectList();
     }
 
@@ -191,7 +196,7 @@ public class GoGenerateService {
             return template.select(Query.query(Criteria.where("type").is(6)
                             .and("group_type_id").is(first.get().getGroupTypeIdSc())
                             .and("deleted_at").isNull()), Material.class)
-                    .onErrorResume(throwable -> Mono.error(new Exception("getImageType1Plan error:" + throwable.getMessage())))
+                    .onErrorResume(throwable -> Mono.error(new BaseException("getImageType1Plan error:" + throwable.getMessage())))
                     .collectList();
         } else {
             return Mono.just(List.of(getMaterialNull()));
@@ -221,7 +226,7 @@ public class GoGenerateService {
     private Mono<List<Image>> getBgImage(Long id) {
         return template.select(Query.query(Criteria.where("type").is(2).and("group_type_id").is(id)
                         .and("deleted_at").isNull()), Image.class)
-                .onErrorResume(throwable -> Mono.error(new Exception("getBgImage error:" + throwable.getMessage())))
+                .onErrorResume(throwable -> Mono.error(new BaseException("getBgImage error:" + throwable.getMessage())))
                 .collectList();
     }
 
@@ -793,7 +798,7 @@ public class GoGenerateService {
                 }
                 return Mono.just(url);
             });
-        }).onErrorResume(throwable -> Mono.error(new Exception("saveAndUpdatePlanGenerateImage1 error:" + throwable.getMessage())));
+        }).onErrorResume(throwable -> Mono.error(new BaseException("saveAndUpdatePlanGenerateImage1 error:" + throwable.getMessage())));
         return stringMono;
     }
 
@@ -813,7 +818,7 @@ public class GoGenerateService {
                         .and("type").is(1)
                         .and("deleted_at").isNull()), DomainSelect.class)
                 .collectList()
-                .onErrorResume(throwable -> Mono.error(new Exception("getImportDomain error:" + throwable.getMessage())))
+                .onErrorResume(throwable -> Mono.error(new BaseException("getImportDomain error:" + throwable.getMessage())))
                 .switchIfEmpty(Mono.just(List.of())).flatMap(b -> {
                     StringBuilder stringBuilder = new StringBuilder();
                     if (Objects.nonNull(b) && !b.isEmpty()) {
@@ -1254,7 +1259,7 @@ public class GoGenerateService {
                     Query query = Query.query(Criteria.where(column).is(planId)).columns("group_id", "code","import_domain");
                     stringMono = template.selectOne(query, PlanNew.class)
                             .switchIfEmpty(Mono.error(new BaseException("自定义二维码:裂变计划查询::PlanId 返回空结果::" + planId)))
-                            .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
+                            .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())))
                             .flatMap(f1 -> {
                                 String code = f1.code();
                                 return getDomainSetV(ftm, planId, type, Long.valueOf(f1.importDomain()), code);
@@ -1263,7 +1268,7 @@ public class GoGenerateService {
                     Query query = Query.query(Criteria.where(column).is(planId)).columns("group_id", "code");
                     stringMono = template.selectOne(query, ListeningPlanNew.class)
                             .switchIfEmpty(Mono.error(new BaseException("自定义二维码:听书计划查询::PlanId  返回空结果::" + planId)))
-                            .onErrorResume(throwable -> Mono.error(new Exception("select ListeningPlanNew::" + throwable.getMessage())))
+                            .onErrorResume(throwable -> Mono.error(new BaseException("select ListeningPlanNew::" + throwable.getMessage())))
                             .flatMap(f1 -> {
                                 String code = f1.code();
                                 return getDomainSetV(ftm, planId, type, f1.groupId(), code);
@@ -1272,14 +1277,14 @@ public class GoGenerateService {
                     Query query = Query.query(Criteria.where(column).is(planId)).columns("group_id", "code","import_domain");
                     stringMono = template.selectOne(query, PlanNewCommon.class)
                             .switchIfEmpty(Mono.error(new BaseException("自定义二维码:交友计划查询::PlanId 返回空结果::" + planId)))
-                            .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
+                            .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())))
                             .flatMap(f1 -> {
                                 String code = f1.code();
                                 return getDomainSetV(ftm, planId, type, Long.valueOf(f1.importDomain()), code);
                             });
                 }
                 return stringMono;
-            }).onErrorResume(throwable -> Mono.error(new Exception("setCusqrcodeSetV error:" + throwable.getMessage()))).collectList();
+            }).onErrorResume(throwable -> Mono.error(new BaseException("setCusqrcodeSetV error:" + throwable.getMessage()))).collectList();
         }
         return Mono.just(List.of(new StringBuilder("无自定义二维码 随机事件")));
     }
@@ -1291,7 +1296,7 @@ public class GoGenerateService {
                         .and("deleted_at").isNull()), DomainSelect.class)
                 .collectList()
                 .switchIfEmpty(Mono.error(new BaseException("自定义二维码:裂变计划类型查询域名::不存在::(groupId::type(1裂變))(" + groupId + "::" + type + ")")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).flatMap(f2 -> {
+                .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()))).flatMap(f2 -> {
                     StringBuilder stringBuilder = new StringBuilder();
                     if (!f2.isEmpty()) {
                         DomainSelect domainSelect = f2.get(RandomUtil.randomInt(0, f2.size()));
@@ -1425,7 +1430,7 @@ public class GoGenerateService {
                     posterRes.setGenerateImagesUrl(url);
                     template.update(Query.query(empty), update, Poster.class)
                             .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
-                            .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
+                            .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())));
                 }
             }
             return posterRes;
@@ -1507,7 +1512,7 @@ public class GoGenerateService {
                         getTextListsTitleSaveOrUpdatePoster(posterRequset)),
                 posterRequset)
                 .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
-                .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
+                .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage())))
                 .flatMap(f -> template.update(f));
         return RStatus.success(posterMono1);
     }
@@ -1528,7 +1533,7 @@ public class GoGenerateService {
         return template.select(Query.query(Criteria.where("type").is(10)
                         .and("group_type_id").in(id)
                         .and("deleted_at").isNull()), Image.class)
-                .onErrorResume(throwable -> Mono.error(new Exception("getImageSaveOrUpdatePlan error:" + throwable.getMessage())))
+                .onErrorResume(throwable -> Mono.error(new BaseException("getImageSaveOrUpdatePlan error:" + throwable.getMessage())))
                 .collectList();
     }
 

+ 77 - 0
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/userVisits/UserVisitsServices.java

@@ -0,0 +1,77 @@
+package com.webflux.launchadmin.mysql.service.userVisits;
+
+import com.plumelog.core.util.LogExceptionStackTrace;
+import com.webflux.launchadmin.global.BaseException;
+import com.webflux.launchadmin.mysql.controller.listening.req.OutListeningShareRequest;
+import com.webflux.launchadmin.mysql.controller.planNew.req.HftRequest;
+import com.webflux.launchadmin.mysql.controller.planNew.req.PlanNewCommonShareReq;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.time.Duration;
+import java.util.Objects;
+
+@Service
+@Slf4j
+public class UserVisitsServices {
+    @Autowired
+    private StringRedisTemplate stringRedisTemplate;
+
+    public Integer getRedisUserVisits(String unique){
+        String s="-1";
+        try {
+            s = stringRedisTemplate.opsForValue().get(unique);
+        }catch (Exception e){
+            log.error("接口异常 desc = {} e = {}", " redis读用户访问次数失败", LogExceptionStackTrace.erroStackTrace(e));
+        }
+        if(Objects.isNull(s) || "".equals(s.trim())){
+            return -1;
+        }
+        try {
+            return Integer.valueOf(s);
+        }catch (Exception e){
+            log.error("接口异常 desc = {} e = {} value={}", "redis读用户访问次数解析Integer错误", LogExceptionStackTrace.erroStackTrace(e), s);
+            return -1;
+        }
+    }
+    public void setRedisUserVisits(String unique,Integer value){
+        try {
+            stringRedisTemplate.opsForValue().set(unique,String.valueOf(value), Duration.ofHours(48));
+        }catch (Exception e){
+            log.error("接口异常 desc = {} e = {}", "redis写入用户访问次数失败", LogExceptionStackTrace.erroStackTrace(e));
+            try {
+                stringRedisTemplate.opsForValue().set(unique,String.valueOf(value), Duration.ofHours(48));
+            }catch (Exception e2){
+                log.error("接口异常 desc = {} e = {}", "重试redis写入用户访问次数失败", LogExceptionStackTrace.erroStackTrace(e2));
+            }
+        }
+    }
+
+    public void setUserVisitsV(HftRequest request) {
+        if(Objects.isNull(request.getUnique()) || "".equals(request.getUnique().trim())){
+            throw new BaseException("unique参数异常 请核对");
+        }
+        Integer redisUserVisits = getRedisUserVisits(request.getUnique())+1;
+        request.setUserVisits(redisUserVisits);
+        setRedisUserVisits(request.getUnique(),redisUserVisits);
+    }
+
+    public void setUserVisitsVLintening(OutListeningShareRequest request) {
+        if(Objects.isNull(request.getUnique()) || "".equals(request.getUnique().trim())){
+            throw new BaseException("unique参数异常 请核对");
+        }
+        Integer redisUserVisits = getRedisUserVisits(request.getUnique())+1;
+        request.setUserVisits(redisUserVisits);
+        setRedisUserVisits(request.getUnique(),redisUserVisits);
+    }
+    public void setUserVisitsCommon(PlanNewCommonShareReq request) {
+        if(Objects.isNull(request.getUnique()) || "".equals(request.getUnique().trim())){
+            throw new BaseException("unique参数异常 请核对");
+        }
+        Integer redisUserVisits = getRedisUserVisits(request.getUnique())+1;
+        request.setUserVisits(redisUserVisits);
+        setRedisUserVisits(request.getUnique(),redisUserVisits);
+    }
+}

+ 15 - 16
launch-common/src/main/java/com/webflux/launchcommon/returnObj/RW.java

@@ -33,19 +33,19 @@ public class RW<T> implements Serializable {
     private T data;
 
     public static <T> Mono<RW<T>> fail(Mono<T> monoData) {
-        return createR(ERR, ERR_MSG,monoData);
+        return createR(ERR, ERR_MSG, monoData);
     }
 
-    public static <T> Mono<RW<T>> fail(String message,Mono<T> monoData) {
+    public static <T> Mono<RW<T>> fail(String message, Mono<T> monoData) {
         return createR(ERR, message, monoData);
     }
 
-    public static <T> Mono<RW<T>> fail(String code, String message,Mono<T> monoData) {
-        return createR(code, message,monoData);
+    public static <T> Mono<RW<T>> fail(String code, String message, Mono<T> monoData) {
+        return createR(code, message, monoData);
     }
 
-    public static <T> Mono<RW<T>> success(String message,Mono<T> monoData) {
-        return createR(OK, message,monoData);
+    public static <T> Mono<RW<T>> success(String message, Mono<T> monoData) {
+        return createR(OK, message, monoData);
     }
 
     public static <T> Mono<RW<T>> success(Mono<T> monoData) {
@@ -53,15 +53,14 @@ public class RW<T> implements Serializable {
     }
 
 
-
-   private static <T> Mono<RW<T>> createR(String code, String msg, Mono<T> monoData){
-      return monoData.map(data->{
-           final RW rw = new RW();
-           rw.setData(data);
-           rw.setCode(code);
-           rw.setMsg(msg);
-           return rw;
-       });
+    private static <T> Mono<RW<T>> createR(String code, String msg, Mono<T> monoData) {
+        return monoData.map(data -> {
+            final RW rw = new RW();
+            rw.setData(data);
+            rw.setCode(code);
+            rw.setMsg(msg);
+            return rw;
+        });
 
     }
 
@@ -80,7 +79,7 @@ public class RW<T> implements Serializable {
         this.data = result;
     }
 
-    public boolean isSuccess(){
+    public boolean isSuccess() {
         return OK.equals(code);
     }
 

+ 3 - 0
launch-redis/src/main/java/com/weblux/launchredis/utils/RedisKey.java

@@ -29,4 +29,7 @@ public class RedisKey {
 
     //.域名相信信息
     public final static String DOMAIN_INFO = "sync_domain_info";
+
+    /** H5客户缓存 */
+    public final static String H5_USER_UNIQUE = "h5_user_unique:";
 }