Browse Source

群列表展示按钮v0.05

(cherry picked from commit ba0f09c53b696b31f3a6a68bc12d56a06629611e)
MOKASZ\lw12420 2 years ago
parent
commit
fede156f5c

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

@@ -71,6 +71,19 @@ public class PlanNewOutController {
         map.clear();
         log.info("清空计划-H5用户Map数据》》》》》》》》》》》》》》》》》》》》》》 结束");
     }
+
+    /**
+     * 获取二维码缓存信息
+     * @param id
+     * @return {@link Mono}<{@link RStatus}<{@link QrcodeInfo}>>
+     */
+    @GetMapping("getQrcode/{id}")
+    public Mono<RStatus<QrcodeInfo>> getQrcode(@PathVariable("id") Long id){
+        Mono<QrcodeInfo> qrcodeInfoMono = template.selectOne(Query.query(Criteria.where("id").is(id)), QrcodeInfo.class)
+                .switchIfEmpty(Mono.error(new BaseException("id异常 查询结果为空")))
+                .onErrorResume(throwable -> Mono.error(new BaseException("查询异常::::" + throwable.getMessage())));
+        return RStatus.success(qrcodeInfoMono);
+    }
     /**
      *通过 code and type 查询 domain
      * @param code
@@ -632,38 +645,61 @@ public class PlanNewOutController {
                 Optional<Item> first1 = goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) && ff.getIsRandom()).findFirst();
                 first1.ifPresent(item -> fm.setGroupHeadUrl(item.getV()));
             }
-            String ret;
-            if (Objects.nonNull(goRequest)) {
-                ret = goGenerateService.goGenerate(JSONUtil.toJsonStr(goRequest));
-            } else {
-
-                ret = goGenerateService.goGenerate(posterTemplate);
+            if (Objects.isNull(goRequest)) {
+                throw  new BaseException("isNull(goRequest) setEndData()");
+            }
+            QrcodeInfo stringBuilder = getQrcodeInfo(goRequest);
+            Mono<QrcodeInfo> qrcodeInfoMono ;
+            if(Objects.nonNull(fm.getPlanNew().groupListDisplay()) && fm.getPlanNew().groupListDisplay()==1){
+                qrcodeInfoMono = template.insert(stringBuilder)
+                                .onErrorResume(throwable -> Mono.error(new BaseException("插入QrcodeInfo异常::::" + throwable.getMessage())));
+            }else {
+                qrcodeInfoMono = Mono.just(stringBuilder);
             }
-            if (Objects.nonNull(ret)) {
-                JSONObject jsonObject1;
-                try {
-                     jsonObject1 =  JSONUtil.parseObj(ret);
-                }catch (Exception e){
-                    throw new BaseException(e.getMessage() +"---"+JSONUtil.parseObj(goRequest));
+           return Mono.zip(qrcodeInfoMono,Mono.just(goRequest),Mono.just(fm)).flatMap(f9->{
+                GoRequest goRequest2 = f9.getT2();
+                if (Objects.nonNull(f9.getT1().id())) {
+                    goRequest2.getItem().stream().filter(f1 -> "qrcode".equals(f1.getT())).forEach(fe->{
+                        if (Objects.nonNull(fe.getV())) {
+                            String qrcode = fe.getV() + "&id=" + f9.getT1().id();
+                            fe.setV(qrcode);
+                        }
+                    });
                 }
-                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()) && !"".equals(request.getWx_user_id())) {
-                            fm.setQsGenerateImagesUrl(url);
-                        } else {
-                            fm.setFxGenerateImagesUrl(url);
+                DataLists0 fm3 = f9.getT3();
+                String ret = goGenerateService.goGenerate(JSONUtil.toJsonStr(goRequest2));
+                if (Objects.nonNull(ret)) {
+                    JSONObject jsonObject1;
+                    try {
+                        jsonObject1 =  JSONUtil.parseObj(ret);
+                    }catch (Exception e){
+                        throw new BaseException(e.getMessage() +"---"+JSONUtil.parseObj(goRequest2));
+                    }
+                    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()) && !"".equals(request.getWx_user_id())) {
+                                fm3.setQsGenerateImagesUrl(url);
+                            } else {
+                                fm3.setFxGenerateImagesUrl(url);
+                            }
                         }
-
                     }
                 }
-            }
-            return Mono.just(fm);
+                return Mono.just(fm3);
+            });
         });
         return dataLists0Mono1;
     }
-
+    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;
+    }
     // 设置封面等
     private Mono<DataLists0> setFmV(HftRequest request, Mono<DataLists0> zip) {
         Mono<DataLists0> dataLists0Mono2 = zip.flatMap(fm -> {

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

@@ -62,7 +62,6 @@ public class GoGenerateService {
         } catch (Exception e) {
             throw new BaseException(e.getMessage() + "body:::" + body + ":::request:::" + temStr);
         }
-
     }
 
     public String goGenerateStr(String temStr) {
@@ -646,8 +645,6 @@ public class GoGenerateService {
                     throw new BaseException("群封面素材为空");
                 }
             }
-            //groupHeadUrl(群头像);groupTitle(群名称)
-            StringBuilder stringBuilder = getStringBuilder(goRequest);
             Optional<Item> first5 = goRequest.getItem().stream().filter(f1 -> "qrcode".equals(f1.getT())).findFirst();
             if (first5.isPresent()) {
                 Item item = first5.get();
@@ -659,7 +656,7 @@ public class GoGenerateService {
                         JSONArray jsonArray = JSONUtil.parseArray(kefu);
                         if (!jsonArray.isEmpty()) {
                             String s = jsonArray.get(0, String.class);
-                            item.setV(s+stringBuilder);
+                            item.setV(s);
                             item.setName("客服二维码");
                         }
                     } else {
@@ -670,7 +667,7 @@ public class GoGenerateService {
                     if ("".equals(t6)) {
                         throw new BaseException("获取H5链接为空");
                     }
-                    item.setV(t6.toString()+stringBuilder);
+                    item.setV(t6.toString());
                     item.setName("H5二维码");
                 }
             }
@@ -745,38 +742,40 @@ public class GoGenerateService {
                     throw new BaseException("文字素材为空");
                 }
             }
-            String s1 = JSONUtil.toJsonStr(goRequest);
-            String ret = goGenerateStr(s1);
-            String url = ret;
-            JSONObject jsonObject1 = JSONUtil.parseObj(ret);
-            if (jsonObject1.containsKey("code") && jsonObject1.get("code", Integer.class) == 0 && jsonObject1.containsKey("data")) {
-                JSONObject data = jsonObject1.get("data", JSONObject.class);
-                if (data.containsKey("Url")) {
-                    url = data.get("Url", String.class);
+           // Integer groupListDisplay = saveRequest.getGroupListDisplay();
+            QrcodeInfo stringBuilder = getQrcodeInfo(goRequest);
+            Mono<QrcodeInfo> qrcodeInfoMono =template.insert(stringBuilder)
+                    .switchIfEmpty(Mono.error(new BaseException("插入异常返回结果为空")))
+                    .onErrorResume(throwable -> Mono.error(new BaseException("插入QrcodeInfo异常::::" + throwable.getMessage())));
+          return Mono.zip(qrcodeInfoMono,Mono.just(goRequest)).flatMap(fff->{
+                GoRequest t21 = fff.getT2();
+                t21.getItem().stream().filter(f1 -> "qrcode".equals(f1.getT())).forEach(fe->{
+                    if (Objects.nonNull(fe.getV())) {
+                        String qrcode = fe.getV() + "&id=" + fff.getT1().id();
+                        fe.setV(qrcode);
+                    }
+                });
+                String s1 = JSONUtil.toJsonStr(t21);
+                String ret = goGenerateStr(s1);
+                String url = ret;
+                JSONObject jsonObject1 = JSONUtil.parseObj(ret);
+                if (jsonObject1.containsKey("code") && jsonObject1.get("code", Integer.class) == 0 && jsonObject1.containsKey("data")) {
+                    JSONObject data = jsonObject1.get("data", JSONObject.class);
+                    if (data.containsKey("Url")) {
+                        url = data.get("Url", String.class);
+                    }
                 }
-            }
-            return Mono.just(url);
+                return Mono.just(url);
+            });
         }).onErrorResume(throwable -> Mono.error(new Exception("saveAndUpdatePlanGenerateImage1 error:" + throwable.getMessage())));
-        ;
         return stringMono;
     }
 
-    private StringBuilder getStringBuilder(GoRequest goRequest)  {
+    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();
-        StringBuilder stringBuilder = new StringBuilder("&groupHeadUrl=");
-        stringBuilder.append(first.isPresent()?first.get().getV():"");
-        stringBuilder.append("&groupTitle=");
-        String encodedParam ="";
-        if(first3.isPresent() &&Objects.nonNull(first3.get().getV())){
-            try {
-                encodedParam = URLEncoder.encode(first3.get().getV(), StandardCharsets.UTF_8.toString());
-            }catch (Exception e){
-                throw new BaseException("URLEncoder Error"+e.getMessage());
-            }
-        }
-        stringBuilder.append(first3.isPresent()?encodedParam:"");
-        return stringBuilder;
+        QrcodeInfo qrcodeInfo = new QrcodeInfo(null,first.isPresent()?first.get().getV():"",first3.isPresent()?first3.get().getV():"");
+        return qrcodeInfo;
     }
 
     public Mono<StringBuilder> getImportDomain(PlanReq saveRequest) {