Procházet zdrojové kódy

裂变优化-v1.0.3

MOKASZ\lw12420 před 2 roky
rodič
revize
311fec7587

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

@@ -136,6 +136,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())))
                 .collectList();
     }
     private Mono<List<Material>> getTextLists() {
@@ -153,6 +154,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())))
                 .collectList();
     }
     private Mono<List<Material>> getTextListsTitle() {
@@ -173,11 +175,12 @@ public class GoGenerateService {
 
     }
     private Mono<List<Material>> getTextListsTitleSaveOrUpdatePlan(GoRequest goRequest) {
-        Optional<Item> first = goRequest.getItem().stream().filter(ft -> "title".equals(ft.getT())).findFirst();
+        Optional<Item> first = goRequest.getItem().stream().filter(ft -> "title".equals(ft.getT()) && ft.getIsRandom()).findFirst();
         if (first.isPresent() && Objects.nonNull(first.get().getGroupTypeIdSc())) {
             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())))
                     .collectList();
         }else {
             return   Mono.just(List.of(getMaterialNull()));
@@ -206,6 +209,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())))
                 .collectList();
     }
 
@@ -543,6 +547,8 @@ public class GoGenerateService {
                                                     saveRequest,
                                                     getTextListsTitleSaveOrUpdatePlan( goRequest));
     }
+
+
     /**
      * 计划保存修改生成图片
      * @param goRequest
@@ -557,7 +563,8 @@ public class GoGenerateService {
                                          Mono<List<Image>> bgImage, Mono<List<Image>> fmImage, Mono<List<Material>> text,Mono<List<Image>> fm1,
                                                         ServiceGroupSettingItemRequest qsSetting,PlanReq saveRequest,Mono<List<Material>> title) {
 
-        Mono<String> stringMono = Mono.zip(bgImage, fmImage, text, stringBuilderMono,fm1,getImportDomain(saveRequest),title).flatMap(f -> {
+        Mono<StringBuilder> importDomain = getImportDomain(saveRequest);
+        Mono<String> stringMono = Mono.zip(bgImage, fmImage, text, stringBuilderMono,fm1,importDomain,title).flatMap(f -> {
             List<StringBuilder> t4 = f.getT4();
 //            if (Objects.nonNull(t4) && !t4.isEmpty()) {
 //                goRequest.getItem().stream().filter(fc->"cusqrcode".equals(fc.getT())).forEach(fe->fe.setName("H5二维码"));
@@ -721,12 +728,12 @@ public class GoGenerateService {
                     }
                 }
             return Mono.just(url);
-        });
+        }) .onErrorResume(throwable -> Mono.error(new Exception("saveAndUpdatePlanGenerateImage1 error:" + throwable.getMessage())));;
         return stringMono;
     }
 
     public Mono<StringBuilder> getImportDomain(PlanReq saveRequest) {
-        if (Objects.isNull(saveRequest.getImportDomain()) || !"".equals(saveRequest.getImportDomain())) {
+        if (Objects.isNull(saveRequest.getImportDomain()) || "".equals(saveRequest.getImportDomain())) {
             throw new BaseException("入口页域名值不可为空");
         }
         return template.select(Query.query(Criteria.where("group_type_id").is(saveRequest.getImportDomain())
@@ -734,6 +741,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())))
                 .switchIfEmpty(Mono.just(List.of())).flatMap(b->{
                     StringBuilder stringBuilder = new StringBuilder();
                     if (Objects.nonNull(b) && !b.isEmpty()) {
@@ -754,7 +762,7 @@ public class GoGenerateService {
     }
     public Mono<StringBuilder> getOutImportDomain(Mono<PlanNew> mono) {
         return mono.flatMap(saveRequest -> {
-            if (Objects.isNull(saveRequest.importDomain()) || !"".equals(saveRequest.importDomain())) {
+            if (Objects.isNull(saveRequest.importDomain()) || "".equals(saveRequest.importDomain())) {
                 throw new BaseException("入口页域名值不可为空");
             }
             return template.select(Query.query(Criteria.where("group_type_id").is(saveRequest.importDomain())
@@ -1069,7 +1077,7 @@ public class GoGenerateService {
                             });
                 }
                 return stringMono;
-            }).collectList();
+            }) .onErrorResume(throwable -> Mono.error(new Exception("setCusqrcodeSetV error:" + throwable.getMessage()))).collectList();
         }
         return Mono.just(List.of(new StringBuilder("无自定义二维码 随机事件")));
     }
@@ -1080,20 +1088,25 @@ public class GoGenerateService {
                 .and("type").is(1)
                 .and("deleted_at").isNull()), DomainSelect.class)
                 .collectList()
-                .switchIfEmpty(Mono.error(new BaseException("自定义二维码:裂变计划类型查询域名::不存在::(planId::type)(" + planId + "::" + type + ")")))
+                .switchIfEmpty(Mono.error(new BaseException("自定义二维码:裂变计划类型查询域名::不存在::(groupId::type(1裂變))(" + groupId + "::" + type + ")")))
                 .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).flatMap(f2 -> {
-                    DomainSelect domainSelect = f2.get(RandomUtil.randomInt(0, f2.size()));
                     StringBuilder stringBuilder = new StringBuilder();
-                    stringBuilder.append("http://");
-                    stringBuilder.append(get6Str());
-                    stringBuilder.append(".");
-                    stringBuilder.append(domainSelect.domain());
-                    stringBuilder.append("/index.html?code=");
-                    stringBuilder.append(code);
-                    stringBuilder.append("&sk=");
-                    stringBuilder.append(IdUtil.fastSimpleUUID());
-                    ftm.setV(stringBuilder.toString());
-                    ftm.setName("H5二维码");
+                    if(!f2.isEmpty()){
+                        DomainSelect domainSelect = f2.get(RandomUtil.randomInt(0, f2.size()));
+                        stringBuilder.append("http://");
+                        stringBuilder.append(get6Str());
+                        stringBuilder.append(".");
+                        stringBuilder.append(domainSelect.domain());
+                        stringBuilder.append("/index.html?code=");
+                        stringBuilder.append(code);
+                        stringBuilder.append("&sk=");
+                        stringBuilder.append(IdUtil.fastSimpleUUID());
+                        ftm.setV(stringBuilder.toString());
+                        ftm.setName("H5二维码");
+                    }else {
+                       throw  new BaseException("自定义二维码:裂变计划类型查询域名::不存在::(groupId::type(1裂變))(" + groupId + "::" + type + ")");
+                    }
+
                     return Mono.just(stringBuilder);
                 });
     }
@@ -1307,6 +1320,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())))
                 .collectList();
     }