Browse Source

plan-java v0.75

(cherry picked from commit 3bc5c16c5a253b3d96ec0d48c7112afefbfa3171)
(cherry picked from commit 66d2d20d14c203e808003f217d55ec8f62d123cd)
MOKASZ\lw12420 2 years ago
parent
commit
2ee24414bb

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

@@ -366,12 +366,22 @@ public class GoGenerateService {
             if (first2.isPresent()) {
                 throw new BaseException("自定义二维码素材为空");
             }
-            Optional<Image> first = f.getT1().stream().findFirst();
+//            Optional<Image> first = f.getT1().stream().findFirst();
+//            if (goRequest.getIsRandom()) {
+//                if (first.isEmpty()) {
+//                    throw new BaseException("背景素材为空");
+//                }
+//                first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
+//            }
+            List<Image> t1 = f.getT1();
             if (goRequest.getIsRandom()) {
-                if (first.isEmpty()) {
+                if (t1.isEmpty()) {
                     throw new BaseException("背景素材为空");
                 }
-                first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
+                int i = RandomUtil.randomInt(0, t1.size());
+                Image image = t1.get(i);
+                goRequest.setBg_img_src(image.image());
+                // first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
             }
             //封面
             List<Image> t5 = f.getT5().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
@@ -505,12 +515,22 @@ public class GoGenerateService {
 //            if (Objects.nonNull(f.getT4()) && !f.getT4().isEmpty()) {
 //
 //            }
-            Optional<Image> first01 = f.getT1().stream().findFirst();
+//            Optional<Image> first01 = f.getT1().stream().findFirst();
+//            if (goRequest.getIsRandom()) {
+//                if (first01.isEmpty()) {
+//                    throw new BaseException("背景素材为空");
+//                }
+//                first01.ifPresent(image -> goRequest.setBg_img_src(image.image()));
+//            }
+            List<Image> t1 = f.getT1();
             if (goRequest.getIsRandom()) {
-                if (first01.isEmpty()) {
+                if (t1.isEmpty()) {
                     throw new BaseException("背景素材为空");
                 }
-                first01.ifPresent(image -> goRequest.setBg_img_src(image.image()));
+                int i = RandomUtil.randomInt(0, t1.size());
+                Image image = t1.get(i);
+                goRequest.setBg_img_src(image.image());
+                // first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
             }
             List<Material> t7 = f.getT7().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
             if (Objects.nonNull(t7) &&!t7.isEmpty()) {
@@ -753,12 +773,16 @@ public class GoGenerateService {
                     throw new BaseException("海报标题素材为空");
                 }
             }
-            Optional<Image> first = f.getT1().stream().findFirst();
+           // Optional<Image> first = f.getT1().stream().findFirst();
+            List<Image> t1 = f.getT1();
             if (goRequest.getIsRandom()) {
-                if (first.isEmpty()) {
+                if (t1.isEmpty()) {
                     throw new BaseException("背景素材为空");
                 }
-                first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
+                int i = RandomUtil.randomInt(0, t1.size());
+                Image image = t1.get(i);
+                goRequest.setBg_img_src(image.image());
+               // first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
             }
             //封面
             List<Image> t5 = f.getT5().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());