|
|
@@ -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());
|