Просмотр исходного кода

海报模版和报复制;二维码链接id添加备注

(cherry picked from commit d9e740c6cdd1b981847b47514bf5e9fd132b4ed3)
MOKASZ\lw12420 1 год назад
Родитель
Сommit
87d461b82b

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

@@ -715,12 +715,7 @@ public class PlanNewCommonOutController {
         // Mono<byte[]> res = resMono1.flatMap(f -> Mono.just(Objects.requireNonNull(this.compressData(JSONUtil.toJsonStr(f)))));
         return RStatus.successList(resMono1);
     }
-    private QrcodeInfo getQrcodeInfo(GoRequest goRequest)  {
-        Optional<Item> first = goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) ).findFirst();
-        Optional<Item> first3 = goRequest.getItem().stream().filter(ff -> "title".equals(ff.getT())).findFirst();
-        QrcodeInfo qrcodeInfo = new QrcodeInfo(null,first.isPresent()?first.get().getV():"",first3.isPresent()?first3.get().getV():"");
-        return qrcodeInfo;
-    }
+
     /**
      * 设置二维码 生成图片
      */

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

@@ -35,10 +35,7 @@ import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
 import java.time.ZonedDateTime;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 
@@ -348,6 +345,56 @@ public class PlanNewController {
     }
 
     /**
+     * 海报模版复制
+     *
+     * @param posterTemplateId
+     * @return {@link Mono}<{@link RStatus}<{@link Long}>>
+     */
+    @GetMapping("copyPosterTemById/{posterTemplateId}")
+    public Mono<RStatus<Long>> copyPosterTemById(@PathVariable("posterTemplateId") @NotNull Long posterTemplateId) {
+        String userName = BaseContextHandler.getUserName();
+        String userId = BaseContextHandler.getUserId();
+        Mono<Long> longMono = template.selectOne(Query.query(Criteria.where("poster_template_id")
+                .is(posterTemplateId)), PosterTemplate.class)
+                .switchIfEmpty(Mono.error(new BaseException("通过海报模版id查询 返回结果为空")))
+                .onErrorResume(throwable -> Mono.error(new BaseException("查询异常" + throwable.getMessage())))
+                .flatMap(fm -> {
+                    PosterTemplate posterTemplate = new PosterTemplate(null,
+                            fm.posterTemplateName() +"-"+ goGenerateService.get7Str(),
+                            userName,
+                            userId,
+                            ZonedDateTime.now(),
+                            null);
+                    Mono<PosterTemplate> insert = template.insert(posterTemplate);
+                    Mono<List<Poster>> poster_template_id1 = template.select(Query.query(Criteria
+                            .where("poster_template_id").is(posterTemplateId)), Poster.class).collectList().switchIfEmpty(Mono.just(List.of()));
+                    return Mono.zip(insert, poster_template_id1).flatMap(f -> {
+                        PosterTemplate t1 = f.getT1();
+                        List<Poster> t2 = f.getT2();
+                        Mono<List<Poster>> listMono ;
+                        if (!t2.isEmpty()) {
+                           listMono = Flux.fromIterable(t2).flatMap(fm1 -> {
+                                Poster poster = new Poster(null,
+                                        t1.posterTemplateId(),
+                                        fm1.posterTemplate(),
+                                        userName,
+                                        userId,
+                                        ZonedDateTime.now(),
+                                        null,
+                                        fm1.generateImagesJson(),
+                                        fm1.generateImagesUrl());
+                                return template.insert(poster);
+                            }).collectList();
+                        }else {
+                            listMono = Mono.just(List.of());
+                        }
+                        return Mono.zip(listMono, Mono.just(t1)).flatMap(end -> Mono.just(end.getT2().posterTemplateId()));
+                    });
+                });
+        return RStatus.success(longMono);
+    }
+
+    /**
      * 海报模版-编辑回显详情
      *
      * @param posterTemplateId

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

@@ -724,7 +724,7 @@ public class PlanNewOutController {
     private QrcodeInfo getQrcodeInfo(GoRequest goRequest)  {
         Optional<Item> first = goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) ).findFirst();
         Optional<Item> first3 = goRequest.getItem().stream().filter(ff -> "title".equals(ff.getT())).findFirst();
-        QrcodeInfo qrcodeInfo = new QrcodeInfo(null,first.isPresent()?first.get().getV():"",first3.isPresent()?first3.get().getV():"");
+        QrcodeInfo qrcodeInfo = new QrcodeInfo(null,first.isPresent()?first.get().getV():"",first3.isPresent()?first3.get().getV():"",first3.isPresent()?first3.get().getRemark():"");
         return qrcodeInfo;
     }
     // 设置封面等

+ 1 - 1
launch-admin/src/main/java/com/webflux/launchadmin/mysql/entity/planNew/QrcodeInfo.java

@@ -4,5 +4,5 @@ import org.springframework.data.annotation.Id;
 import org.springframework.data.relational.core.mapping.Table;
 
 @Table("qrcode_info")
-public record QrcodeInfo(@Id Long  id,String url,String title) {
+public record QrcodeInfo(@Id Long  id,String url,String title,String remark) {
 }

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

@@ -411,6 +411,7 @@ public class GoGenerateService {
                         .findFirst()
                         .ifPresent(item -> {
                             item.setV(material.content());
+                            item.setRemark(material.remark());
                         }));
             } else {
                 Optional<Item> first = goRequest.getItem().stream()
@@ -637,6 +638,7 @@ public class GoGenerateService {
                         .findFirst()
                         .ifPresent(item -> {
                             item.setV(material.content());
+                            item.setRemark(material.remark());
                         }));
             } else {
                 Optional<Item> first = goRequest.getItem().stream()
@@ -813,7 +815,7 @@ public class GoGenerateService {
     private QrcodeInfo getQrcodeInfo(GoRequest goRequest)  {
         Optional<Item> first = goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) ).findFirst();
         Optional<Item> first3 = goRequest.getItem().stream().filter(ff -> "title".equals(ff.getT())).findFirst();
-        QrcodeInfo qrcodeInfo = new QrcodeInfo(null,first.isPresent()?first.get().getV():"",first3.isPresent()?first3.get().getV():"");
+        QrcodeInfo qrcodeInfo = new QrcodeInfo(null,first.isPresent()?first.get().getV():"",first3.isPresent()?first3.get().getV():"",first3.isPresent()?first3.get().getRemark():"");
         return qrcodeInfo;
     }
     @Value("${go.data.contactWay}")
@@ -1438,7 +1440,10 @@ public class GoGenerateService {
         String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
         return string;
     }
-
+    public String get7Str() {
+        String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 7);
+        return string;
+    }
     private Mono<Poster> getPosterResMono1(Mono<PosterRequest> insert, Mono<String> stringMono) {
         Mono<Poster> zip = Mono.zip(insert, stringMono, (entry, ret) -> {
             JSONObject jsonObject1 = JSONUtil.parseObj(ret);

+ 2 - 0
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/planNew/structure/Item.java

@@ -47,6 +47,8 @@ public class Item {
 
     private Boolean isChannel;//前端替换
 
+    private String remark;
+
     private String planId;
 
     private Long  groupTypeIdQs;