|
|
@@ -10,18 +10,22 @@ import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.plumelog.core.util.LogExceptionStackTrace;
|
|
|
import com.webflux.launchadmin.global.BaseException;
|
|
|
+import com.webflux.launchadmin.mysql.controller.otherServices.res.ByCodeGetImportDomainRes;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.req.*;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.res.*;
|
|
|
+import com.webflux.launchadmin.mysql.controller.sourceMaterial.data.album.AlbumReq;
|
|
|
import com.webflux.launchadmin.mysql.controller.takeawayController.res.TakeawayH5Data;
|
|
|
import com.webflux.launchadmin.mysql.entity.groupUsers.GroupUsers;
|
|
|
import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
|
|
|
import com.webflux.launchadmin.mysql.entity.planNew.*;
|
|
|
+import com.webflux.launchadmin.mysql.entity.sourceMaterial.Album;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.PlanServiceInterface;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.goGenerate.GoGenerateService;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.ipAnalyze.IpAnalyzeServiceInterface;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.structure.Item;
|
|
|
import com.webflux.launchadmin.mysql.service.readBookPlan.ReadBookPlanServicesInterface;
|
|
|
+import com.webflux.launchadmin.mysql.service.sourceMaterial.materialManagement.MaterialManagementInterface;
|
|
|
import com.webflux.launchadmin.mysql.service.takeaway.TakeawayServicesInterface;
|
|
|
import com.webflux.launchcommon.returnObj.RStatus;
|
|
|
import com.webflux.launchcommon.utils.StringUtils;
|
|
|
@@ -36,6 +40,7 @@ import org.springframework.data.relational.core.query.Query;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
|
+import reactor.core.publisher.Flux;
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
@@ -45,8 +50,11 @@ import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.IntStream;
|
|
|
+import java.util.stream.Stream;
|
|
|
import java.util.zip.GZIPOutputStream;
|
|
|
|
|
|
+import static reactor.util.concurrent.Queues.get;
|
|
|
+
|
|
|
/**
|
|
|
* 通用计划-H5
|
|
|
*
|
|
|
@@ -70,7 +78,8 @@ public class PlanNewCommonOutController {
|
|
|
|
|
|
@Resource
|
|
|
private PlanServiceInterface planServiceInterface;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private MaterialManagementInterface sourceMaterialInterface;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -482,7 +491,7 @@ public class PlanNewCommonOutController {
|
|
|
} else if (2 == request.getTypePlan()) {
|
|
|
// 听书裂变
|
|
|
return this.getListeningPlan(request);
|
|
|
- } else if (3 == request.getTypePlan() ||6 == request.getTypePlan() ) {
|
|
|
+ } else if (3 == request.getTypePlan() ||6 == request.getTypePlan() ||7 == request.getTypePlan()) {
|
|
|
// 交友裂变
|
|
|
return this.getFriendPlan(request);
|
|
|
} else if (4 == request.getTypePlan()) {
|
|
|
@@ -754,19 +763,37 @@ public class PlanNewCommonOutController {
|
|
|
}
|
|
|
Mono<List<Ad>> adtop ;
|
|
|
if (Objects.nonNull(request.getTopAdvBl()) && request.getTopAdvBl()) {
|
|
|
- adtop = template.select(Query.query(Criteria.where("type").is(1)
|
|
|
- .and("deleted_at").isNull()).columns("id,name,type,image,show_beg_at,show_end_at,link".split(",")), Ad.class)
|
|
|
- .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"4")))
|
|
|
- .collectList();////广告类型1顶部2底部3返回4安卓,ios的返回
|
|
|
+ if(6==plan.type()){
|
|
|
+ adtop = template.select(Query.query(Criteria.where("type").is(1).and("group_type_id").is(plan.groupId())
|
|
|
+ .and("deleted_at").isNull()).columns("id,name,type,image,show_beg_at,show_end_at,link".split(",")), Ad.class)
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划营销分类:{};查询顶部广告返回结果为空",plan.groupId()))))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"4")))
|
|
|
+ .collectList();////广告类型1顶部2底部3返回4安卓,ios的返回
|
|
|
+ }else {
|
|
|
+ adtop = template.select(Query.query(Criteria.where("type").is(1)
|
|
|
+ .and("deleted_at").isNull()).columns("id,name,type,image,show_beg_at,show_end_at,link".split(",")), Ad.class)
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"4")))
|
|
|
+ .collectList();////广告类型1顶部2底部3返回4安卓,ios的返回
|
|
|
+ }
|
|
|
+
|
|
|
}else {
|
|
|
adtop=Mono.just(List.of());
|
|
|
}
|
|
|
Mono<List<Ad>> adBottom ;
|
|
|
if (Objects.nonNull(request.getBottomAdvBl()) && request.getBottomAdvBl()) {
|
|
|
- adBottom = template.select(Query.query(Criteria.where("type").is(2)
|
|
|
- .and("deleted_at").isNull()).columns("id,name,type,image,show_beg_at,show_end_at,link".split(",")), Ad.class)
|
|
|
- .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"4")))
|
|
|
- .collectList();////广告类型1顶部2底部3返回4安卓,ios的返回
|
|
|
+ if (6 == plan.type()) {
|
|
|
+ adBottom = template.select(Query.query(Criteria.where("type").is(2).and("group_type_id").is(plan.groupId())
|
|
|
+ .and("deleted_at").isNull()).columns("id,name,type,image,show_beg_at,show_end_at,link".split(",")), Ad.class)
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划营销分类:{};查询底部广告返回结果为空",plan.groupId()))))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"4")))
|
|
|
+ .collectList();////广告类型1顶部2底部3返回4安卓,ios的返回
|
|
|
+ }else {
|
|
|
+ adBottom = template.select(Query.query(Criteria.where("type").is(2)
|
|
|
+ .and("deleted_at").isNull()).columns("id,name,type,image,show_beg_at,show_end_at,link".split(",")), Ad.class)
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException(throwable.getMessage()+"4")))
|
|
|
+ .collectList();////广告类型1顶部2底部3返回4安卓,ios的返回
|
|
|
+ }
|
|
|
+
|
|
|
}else {
|
|
|
adBottom=Mono.just(List.of());
|
|
|
}
|
|
|
@@ -780,22 +807,88 @@ public class PlanNewCommonOutController {
|
|
|
}else {
|
|
|
imageMono=Mono.just(List.of());
|
|
|
}
|
|
|
-
|
|
|
- return Mono.zip(groupAudio, retAudio, returnLoop, backgroupImageItemMono, takeaway,adtop,adBottom,imageMono).flatMap(f -> {
|
|
|
+ Mono<Ad> adTop1 = adtop.flatMap(t6 -> {
|
|
|
+ Mono<Ad> adMono = Mono.just(new Ad(null, null, null, null, null
|
|
|
+ , null, null, null, null, null, null, null, null, null));
|
|
|
+ if (!t6.isEmpty()) {
|
|
|
+ Ad ad = t6.get(RandomUtil.randomInt(0, t6.size()));
|
|
|
+ if(6==plan.type() && Objects.nonNull(request.getTopAdvBl()) && request.getTopAdvBl()){
|
|
|
+ if (Objects.nonNull(ad.redirectType()) && ad.redirectType() == 1 && Objects.nonNull(ad.planId())&& Objects.nonNull(ad.planType())) {
|
|
|
+ Mono<String> byCodeGetImportDomainResMono = getByCodeGetImportDomainResMono(ad.planId(), ad.planType()).switchIfEmpty(Mono.just(""));
|
|
|
+ adMono = Mono.zip(Mono.just(ad), byCodeGetImportDomainResMono).flatMap(tuple -> {
|
|
|
+ Ad t1 = tuple.getT1();
|
|
|
+ String t2 = tuple.getT2();
|
|
|
+ Ad ad1 = new Ad(t1.id(), t1.name(), null, null, null
|
|
|
+ , t1.type(), t1.image(), t1.showBegAt(), t1.showBegAt(), t2, t1.redirectType(),
|
|
|
+ t1.planType(), t1.planId(), t1.groupTypeId());
|
|
|
+ return Mono.just(ad1);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ adMono=Mono.just(ad);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ adMono=Mono.just(ad);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return adMono;
|
|
|
+ });
|
|
|
+ Mono<Ad> adBottom2 = adBottom.flatMap(t6 -> {
|
|
|
+ Mono<Ad> adMono = Mono.just(new Ad(null, null, null, null, null
|
|
|
+ , null, null, null, null, null, null, null, null, null));
|
|
|
+ if (!t6.isEmpty()) {
|
|
|
+ Ad ad = t6.get(RandomUtil.randomInt(0, t6.size()));
|
|
|
+ if(6==plan.type() && Objects.nonNull(request.getTopAdvBl()) && request.getTopAdvBl()){
|
|
|
+ if (Objects.nonNull(ad.redirectType()) && ad.redirectType() == 1 && Objects.nonNull(ad.planId())&& Objects.nonNull(ad.planType())) {
|
|
|
+ Mono<String> byCodeGetImportDomainResMono = getByCodeGetImportDomainResMono(ad.planId(), ad.planType()).switchIfEmpty(Mono.just(""));
|
|
|
+ adMono = Mono.zip(Mono.just(ad), byCodeGetImportDomainResMono).flatMap(tuple -> {
|
|
|
+ Ad t1 = tuple.getT1();
|
|
|
+ String t2 = tuple.getT2();
|
|
|
+ Ad ad1 = new Ad(t1.id(), t1.name(), null, null, null
|
|
|
+ , t1.type(), t1.image(), t1.showBegAt(), t1.showBegAt(), t2, t1.redirectType(),
|
|
|
+ t1.planType(), t1.planId(), t1.groupTypeId());
|
|
|
+ return Mono.just(ad1);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ adMono=Mono.just(ad);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ adMono=Mono.just(ad);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return adMono;
|
|
|
+ });
|
|
|
+ Mono<List<AlbumReq>> albumList = Mono.just(List.of());
|
|
|
+ if (Objects.nonNull(request.getAlbumNum()) && 0 != request.getAlbumNum()) {
|
|
|
+ Mono<List<Long>> album_id = template.select(Query.query(Criteria.empty()).columns("album_id"), Album.class).flatMap(album -> Mono.just(album.albumId())).collectList();
|
|
|
+ albumList = album_id.flatMap(lists -> {
|
|
|
+ if (lists.isEmpty() || lists.size() < request.getAlbumNum()) {
|
|
|
+ return Mono.error(new BaseException(StrUtil.format("相册素材数:{};计划要求素材数:{} 不匹配", lists.size(), request.getAlbumNum())));
|
|
|
+ }
|
|
|
+ List<Long> longs = new ArrayList<>();
|
|
|
+ for (int i = 0; i < request.getAlbumNum(); i++) {
|
|
|
+ List<Long> collect = lists.stream().filter(f -> !longs.contains(f)).collect(Collectors.toList());
|
|
|
+ Long aLong = collect.get(RandomUtil.randomInt(0, lists.size()));
|
|
|
+ longs.add(aLong);
|
|
|
+ }
|
|
|
+ Mono<List<AlbumReq>> listMono = Flux.fromIterable(longs).flatMap(id -> {
|
|
|
+ return sourceMaterialInterface.infoAlbum(id);
|
|
|
+ }).collectList();
|
|
|
+ return listMono;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ Mono<PlanNewCommonMaterialRes> planNewCommonMaterialResMono = Mono.zip(groupAudio, retAudio, returnLoop, backgroupImageItemMono, takeaway, adTop1, adBottom2, imageMono).flatMap(f -> {
|
|
|
PlanNewCommonMaterialRes materialRes = new PlanNewCommonMaterialRes();
|
|
|
materialRes.setGroupAudio(f.getT1());
|
|
|
materialRes.setRetAudio(f.getT2());
|
|
|
materialRes.setReturnLoop(f.getT3());
|
|
|
materialRes.setTakeawayH5Data(f.getT5());
|
|
|
- List<Ad> t6 = f.getT6();
|
|
|
- if (!t6.isEmpty()) {
|
|
|
- Ad ad = t6.get(RandomUtil.randomInt(0, t6.size()));
|
|
|
- materialRes.setTopAdv(ad);
|
|
|
+ Ad t6 = f.getT6();
|
|
|
+ if (Objects.nonNull(t6.id())) {
|
|
|
+ materialRes.setTopAdv(t6);
|
|
|
}
|
|
|
- List<Ad> t7 = f.getT7();
|
|
|
- if (!t7.isEmpty()) {
|
|
|
- Ad ad = t7.get(RandomUtil.randomInt(0, t7.size()));
|
|
|
- materialRes.setBottomAdv(ad);
|
|
|
+ Ad t7 = f.getT7();
|
|
|
+ if (Objects.nonNull(t7.id())) {
|
|
|
+ materialRes.setBottomAdv(t7);
|
|
|
}
|
|
|
List<Image> t8 = f.getT8();
|
|
|
if (!t8.isEmpty()) {
|
|
|
@@ -807,6 +900,14 @@ public class PlanNewCommonOutController {
|
|
|
}
|
|
|
return Mono.just(materialRes);
|
|
|
});
|
|
|
+ return Mono.zip(planNewCommonMaterialResMono,albumList).flatMap(tuple->{
|
|
|
+ List<AlbumReq> t2 = tuple.getT2();
|
|
|
+ PlanNewCommonMaterialRes t1 = tuple.getT1();
|
|
|
+ if(!t2.isEmpty()){
|
|
|
+ t1.setAlbumList(t2);
|
|
|
+ }
|
|
|
+ return Mono.just(t1);
|
|
|
+ });
|
|
|
});
|
|
|
// GZIP压缩
|
|
|
// Mono<byte[]> res = materialResMono.flatMap(f -> Mono.just(Objects.requireNonNull(this.compressData(JSONUtil.toJsonStr(f)))));
|
|
|
@@ -1164,4 +1265,197 @@ public class PlanNewCommonOutController {
|
|
|
private Mono<StringBuilder> getEwm(Mono<PlanNewCommon> code) {
|
|
|
return goGenerateService.getOutImportDomainCommon(code);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public Mono<String> getByCodeGetImportDomainResMono(String planId,Integer planType) {
|
|
|
+ Query query0 = Query.query(Criteria.where("plan_new_id").is(planId));
|
|
|
+ Mono<Long> planNew = Mono.just(0L);
|
|
|
+ if (1 == planType) {
|
|
|
+ planNew = template.count(query0, PlanNew.class)
|
|
|
+ .onErrorResume(throwable ->
|
|
|
+ Mono.error(new Exception(StrUtil
|
|
|
+ .format("通过planid:{}查询是否裂变计划异常:::{}",
|
|
|
+ planId,
|
|
|
+ throwable.getMessage()))));
|
|
|
+ }
|
|
|
+ Query query1 = Query.query(Criteria.where("listening_plan_new_id").is(planId));
|
|
|
+ Mono<Long> listeningPlan = Mono.just(0L) ;
|
|
|
+ if (2 == planType) {
|
|
|
+ listeningPlan = template
|
|
|
+ .count(query1, ListeningPlanNew.class)
|
|
|
+ .onErrorResume(throwable ->
|
|
|
+ Mono.error(new Exception(StrUtil
|
|
|
+ .format("通过planId:{}查询是否听书计划异常:::{}",
|
|
|
+ planId,
|
|
|
+ throwable.getMessage()))));
|
|
|
+ }
|
|
|
+ Mono<Long> common = Mono.just(0L) ;
|
|
|
+ Query query2 = Query.query(Criteria.where("id").is(planId));
|
|
|
+ if (planType > 2) {
|
|
|
+ common = template
|
|
|
+ .count(query2, PlanNewCommon.class)
|
|
|
+ .onErrorResume(throwable ->
|
|
|
+ Mono.error(new Exception(StrUtil
|
|
|
+ .format("通过planId:{}查询计划异常:::{}",
|
|
|
+ planId,
|
|
|
+ throwable.getMessage()))));
|
|
|
+ }
|
|
|
+ Mono<String> stringBuilderMono1 = Mono
|
|
|
+ .zip(planNew, listeningPlan,common)
|
|
|
+ .flatMap(f -> {
|
|
|
+ Long t1 = f.getT1();
|
|
|
+ Long t2 = f.getT2();
|
|
|
+ Long t3 = f.getT3();
|
|
|
+ Mono<ByCodeGetImportDomainRes> stringBuilderMono;
|
|
|
+ if (t1 > 0) {
|
|
|
+ stringBuilderMono = getNewPlan(planId, query0);
|
|
|
+ } else if (t2 > 0) {
|
|
|
+ stringBuilderMono = getNewListeningNewPlan(planId, query1);
|
|
|
+ } else if(t3>0){
|
|
|
+ stringBuilderMono = getNewPlanCommon(planId, query2);
|
|
|
+ }else {
|
|
|
+ throw new BaseException("planId不存在");
|
|
|
+ }
|
|
|
+ return stringBuilderMono.flatMap(f1->Mono.just(f1.getDomain()));
|
|
|
+ });
|
|
|
+ return stringBuilderMono1;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Mono<ByCodeGetImportDomainRes> getNewPlanCommon(String planId, Query query) {
|
|
|
+ return template.selectOne(query, PlanNewCommon.class)
|
|
|
+ .switchIfEmpty(Mono
|
|
|
+ .error(new BaseException(StrUtil
|
|
|
+ .format("通过planId:{}查询common计划异常:::{}",
|
|
|
+ planId,
|
|
|
+ "返回结构为空"))))
|
|
|
+ .onErrorResume(throwable ->
|
|
|
+ Mono.error(new BaseException(StrUtil
|
|
|
+ .format("通过planId:{}查询common计划异常:::{}",
|
|
|
+ planId,
|
|
|
+ throwable.getMessage()))))
|
|
|
+ .flatMap(ff -> {
|
|
|
+ Long groupId = ff.groupId();
|
|
|
+ if (Objects.isNull(groupId)) {
|
|
|
+ return Mono.error(new BaseException("查询common计划 groupId 值为 null"));
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(ff.type()) && 5==ff.type()){
|
|
|
+ String configJson = ff.configJson();
|
|
|
+ if(Objects.nonNull(configJson) ){
|
|
|
+ JSONObject jsonObject;
|
|
|
+ try {
|
|
|
+ jsonObject = JSONUtil.parseObj(configJson);
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new BaseException("解析configJson异常"+e.getMessage());
|
|
|
+ }
|
|
|
+ if(!jsonObject.containsKey("landingPageDomain")){
|
|
|
+ throw new BaseException("解析configJson 不包含字段 landingPageDomain");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ groupId = jsonObject.get("landingPageDomain", Long.class);
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new BaseException("解析landingPageDomain异常"+e.getMessage());
|
|
|
+ }
|
|
|
+ // String s = byCustomerIdGetUrl(posterCustomerServiceId);
|
|
|
+ //return Mono.just(new StringBuilder(s));
|
|
|
+ }
|
|
|
+ //saveRequest.setImportDomain(String.valueOf(saveRequest.getGroupId()));
|
|
|
+ }
|
|
|
+ return getDomainSetV(groupId, planId,2, ff.code());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ private Mono<ByCodeGetImportDomainRes> getNewListeningNewPlan(String planId, Query query) {
|
|
|
+ return template.selectOne(query, ListeningPlanNew.class)
|
|
|
+ .switchIfEmpty(Mono
|
|
|
+ .error(new BaseException(StrUtil
|
|
|
+ .format("通过planId:{}查询裂变计划异常:::{}",
|
|
|
+ planId,
|
|
|
+ "返回结构为空"))))
|
|
|
+ .onErrorResume(throwable ->
|
|
|
+ Mono.error(new BaseException(StrUtil
|
|
|
+ .format("通过planId:{}查询裂变计划异常:::{}",
|
|
|
+ planId,
|
|
|
+ throwable.getMessage()))))
|
|
|
+ .flatMap(ff -> {
|
|
|
+ Long groupId = ff.groupId();
|
|
|
+ if (Objects.isNull(groupId)) {
|
|
|
+ return Mono.error(new BaseException("查询裂变计划 groupId 值为 null"));
|
|
|
+ }
|
|
|
+ return getDomainSetV(groupId, planId,1, ff.code());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private Mono<ByCodeGetImportDomainRes> getNewPlan(String planId, Query query) {
|
|
|
+ return template.selectOne(query, PlanNew.class)
|
|
|
+ .switchIfEmpty(Mono
|
|
|
+ .error(new BaseException(StrUtil
|
|
|
+ .format("通过planId:{}查询裂变计划异常:::{}",
|
|
|
+ planId,
|
|
|
+ "返回结构为空"))))
|
|
|
+ .onErrorResume(throwable ->
|
|
|
+ Mono.error(new BaseException(StrUtil
|
|
|
+ .format("通过planId:{}查询裂变计划异常:::{}",
|
|
|
+ planId,
|
|
|
+ throwable.getMessage()))))
|
|
|
+ .flatMap(ff -> {
|
|
|
+ String groupIdStr = ff.importDomain();
|
|
|
+ if (Objects.isNull(groupIdStr)) {
|
|
|
+ return Mono.error(new BaseException("查询听书计划入口域名类型值为 null"));
|
|
|
+ }
|
|
|
+ long groupId;
|
|
|
+ try {
|
|
|
+ groupId = Long.parseLong(groupIdStr);
|
|
|
+ }catch (Exception e){
|
|
|
+ return Mono.error(new BaseException("查询听书计划入口域名类型值解析错误"+e.getMessage()));
|
|
|
+ }
|
|
|
+ return getDomainSetV(groupId, planId,1,ff.code());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private Mono<ByCodeGetImportDomainRes> getDomainSetV( Long groupId, String planId,Integer type,String code) {
|
|
|
+ return template.select(Query.query(Criteria.where("group_type_id").is(groupId)
|
|
|
+ .and("status").is(1)
|
|
|
+ .and("type").is(type)
|
|
|
+ .and("deleted_at").isNull()),
|
|
|
+ DomainSelect.class)
|
|
|
+ .collectList()
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException(StrUtil
|
|
|
+ .format("通过planId:{},groupId:{};查询域名为空",
|
|
|
+ planId,
|
|
|
+ groupId))))
|
|
|
+ .onErrorResume(throwable ->
|
|
|
+ Mono.error(new Exception(StrUtil
|
|
|
+ .format("通过planId:{},groupId:{};查询域名Error::{}",
|
|
|
+ planId,
|
|
|
+ groupId,
|
|
|
+ throwable.getMessage()))))
|
|
|
+ .flatMap(f2 -> {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ if(!f2.isEmpty()){
|
|
|
+ DomainSelect domainSelect = f2.get(RandomUtil.randomInt(0, f2.size()));
|
|
|
+ stringBuilder.append("http://");
|
|
|
+ stringBuilder.append(get6Str());
|
|
|
+ stringBuilder.append(".");
|
|
|
+ stringBuilder.append(domainSelect.domain());
|
|
|
+ if(2==type){
|
|
|
+ stringBuilder.append("?code=");
|
|
|
+ }else {
|
|
|
+ stringBuilder.append("/index.html?code=");
|
|
|
+ }
|
|
|
+
|
|
|
+ stringBuilder.append(code);
|
|
|
+ stringBuilder.append("&sk=");
|
|
|
+ stringBuilder.append(IdUtil.fastSimpleUUID());
|
|
|
+ }else {
|
|
|
+ return Mono.error(new BaseException(StrUtil.format("通过code:{},groupId:{};查询域名Error::{}",code,groupId,"错误")));
|
|
|
+ }
|
|
|
+ ByCodeGetImportDomainRes domain = new ByCodeGetImportDomainRes();
|
|
|
+ domain.setDomain(stringBuilder.toString());
|
|
|
+ return Mono.just(domain);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ private String get6Str() {
|
|
|
+ return RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|