|
|
@@ -62,18 +62,22 @@ public class GoGenerateService {
|
|
|
|
|
|
}
|
|
|
public String goGenerateStr(String temStr){
|
|
|
+ String body="";
|
|
|
try {
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(temStr);
|
|
|
- String body = HttpUtil.post(value + "/api/image/createImage",temStr,100000);
|
|
|
+ //JSONObject jsonObject = JSONUtil.parseObj(temStr);
|
|
|
+ body = HttpUtil.post(value + "/api/image/createImage",temStr,100000);
|
|
|
+ JSONUtil.parseObj(body);
|
|
|
return body;
|
|
|
} catch (Exception e) {
|
|
|
// System.out.println(e);
|
|
|
- throw new BaseException(e.getMessage());
|
|
|
+ throw new BaseException(e.getMessage() + "body:::" +body);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
public Mono<RStatus<Poster>> savePoster(PosterRequest posterRequset){
|
|
|
|
|
|
String posterTemplate = posterRequset.getPosterTemplate();
|
|
|
@@ -81,21 +85,26 @@ public class GoGenerateService {
|
|
|
GoRequest goRequest = new GoRequest();
|
|
|
BeanUtil.copyProperties(jsonObject,goRequest);//cusqrcode
|
|
|
Mono<List<StringBuilder>> stringBuilderMono = getStringBuilderMono(goRequest);
|
|
|
- Mono<Poster> posterMono1 ;
|
|
|
- if (goRequest.getIsRandom()) {
|
|
|
- posterMono1 = getPosterResMono1(Mono.just(posterRequset),
|
|
|
- getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1()))
|
|
|
- .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
- .flatMap(f -> template.insert(f));
|
|
|
- }else {
|
|
|
- posterMono1 = getPosterResMono1(Mono.just(posterRequset),
|
|
|
- stringBuilderMono.flatMap(f -> Mono.just(goGenerateStr(JSONUtil.toJsonStr(goRequest)))))
|
|
|
- .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
- .flatMap(f -> template.insert(f));
|
|
|
- // return RStatus.success(posterMono1);
|
|
|
- }
|
|
|
+
|
|
|
+ Mono<Poster> posterMono1 = getPosterResMono1(Mono.just(posterRequset),
|
|
|
+ getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1()))
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
+ .flatMap(f -> template.insert(f));
|
|
|
+// if (goRequest.getIsRandom()) {
|
|
|
+// posterMono1 = getPosterResMono1(Mono.just(posterRequset),
|
|
|
+// getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1()))
|
|
|
+// .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
+// .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
+// .flatMap(f -> template.insert(f));
|
|
|
+// }else {
|
|
|
+// posterMono1 = getPosterResMono1(Mono.just(posterRequset),
|
|
|
+// stringBuilderMono.flatMap(f -> Mono.just(goGenerateStr(JSONUtil.toJsonStr(goRequest)))))
|
|
|
+// .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
+// .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
+// .flatMap(f -> template.insert(f));
|
|
|
+// // return RStatus.success(posterMono1);
|
|
|
+// }
|
|
|
return RStatus.success(posterMono1);
|
|
|
}
|
|
|
|
|
|
@@ -111,6 +120,7 @@ public class GoGenerateService {
|
|
|
return template.select(Query.query(Criteria.where("type").is(14)), Material.class).collectList();
|
|
|
}
|
|
|
|
|
|
+ //背景
|
|
|
private Mono<List<Image>> getBgImage() {
|
|
|
return template.select(Query.query(Criteria.where("type").is(2)), Image.class).collectList();
|
|
|
}
|
|
|
@@ -328,6 +338,7 @@ public class GoGenerateService {
|
|
|
if (goRequest.getIsRandom()) {
|
|
|
first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
|
|
|
}
|
|
|
+ goRequest.getItem().stream().filter(fc->"cusqrcode".equals(fc.getT())).forEach(fe->fe.setName("H5二维码"));
|
|
|
//封面
|
|
|
goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) && ff.getIsRandom()).findFirst()
|
|
|
.ifPresent(item -> item.setV(f.getT5().get(RandomUtil.randomInt(0, f.getT5().size())).image()));
|
|
|
@@ -341,6 +352,7 @@ public class GoGenerateService {
|
|
|
.filter(ff -> "text".equals(ff.getT()) && ff.getIsRandom())
|
|
|
.findFirst()
|
|
|
.ifPresent(item -> item.setV(material.content())));
|
|
|
+
|
|
|
String s1 = JSONUtil.toJsonStr(goRequest);
|
|
|
String s = goGenerateStr(s1);
|
|
|
return Mono.just(s);
|
|
|
@@ -506,21 +518,27 @@ public class GoGenerateService {
|
|
|
GoRequest goRequest = new GoRequest();
|
|
|
BeanUtil.copyProperties(jsonObject,goRequest);
|
|
|
Mono<List<StringBuilder>> stringBuilderMono = getStringBuilderMono(goRequest);
|
|
|
- if (goRequest.getIsRandom()) {
|
|
|
- Mono<Poster> posterMono1 = getPosterResMonoUpdate(Mono.just(posterRequset),
|
|
|
- getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1()),posterRequset)
|
|
|
- .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
- .flatMap(f -> template.update(f));
|
|
|
- return RStatus.success(posterMono1);
|
|
|
- }else {
|
|
|
- Mono<Poster> posterMono1 = getPosterResMonoUpdate(Mono.just(posterRequset),
|
|
|
- stringBuilderMono.flatMap(f -> Mono.just(goGenerateStr(JSONUtil.toJsonStr(goRequest)))),posterRequset)
|
|
|
- .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
- .flatMap(f -> template.update(f));
|
|
|
- return RStatus.success(posterMono1);
|
|
|
- }
|
|
|
+ Mono<Poster> posterMono1 = getPosterResMonoUpdate(Mono.just(posterRequset),
|
|
|
+ getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1()),posterRequset)
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
+ .flatMap(f -> template.update(f));
|
|
|
+ return RStatus.success(posterMono1);
|
|
|
+// if (goRequest.getIsRandom()) {
|
|
|
+// Mono<Poster> posterMono1 = getPosterResMonoUpdate(Mono.just(posterRequset),
|
|
|
+// getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1()),posterRequset)
|
|
|
+// .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
+// .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
+// .flatMap(f -> template.update(f));
|
|
|
+// return RStatus.success(posterMono1);
|
|
|
+// }else {
|
|
|
+// Mono<Poster> posterMono1 = getPosterResMonoUpdate(Mono.just(posterRequset),
|
|
|
+// stringBuilderMono.flatMap(f -> Mono.just(goGenerateStr(JSONUtil.toJsonStr(goRequest)))),posterRequset)
|
|
|
+// .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
+// .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
+// .flatMap(f -> template.update(f));
|
|
|
+// return RStatus.success(posterMono1);
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|