|
|
@@ -183,24 +183,23 @@ public class PlanNewOutController {
|
|
|
throw new BaseException("未获取到计划信息");
|
|
|
}
|
|
|
ListeningPlanNew planInfo = com.alibaba.fastjson.JSONObject.parseObject(planCache.toString(),ListeningPlanNew.class);
|
|
|
-// Mono<ListeningPlanNew> code1 = template.selectOne(Query.query(Criteria.where("code").is(code)), ListeningPlanNew.class)
|
|
|
-// .switchIfEmpty(Mono.error(new BaseException("计划code异常 返回结果为空"))) //Mono.error(new BaseException("查询海报模版 id:"+f.posterTemplateId()+"=>空"))
|
|
|
-// .onErrorResume(throwable -> Mono.error(new Exception( throwable.getMessage())));
|
|
|
-
|
|
|
- Mono<DomainSelectRes> domainSelectResMono1 = template.select(Query.query(Criteria.where("group_type_id").is(planInfo.groupId())
|
|
|
- .and("status").is(1).and("type").is(type).and("deleted_at").isNull()), DomainSelect.class)
|
|
|
- .switchIfEmpty(Mono.error(new BaseException("查询domain 返回结果为空")))
|
|
|
- .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).collectList().flatMap(fm -> {
|
|
|
- DomainSelectRes domainSelectRes = new DomainSelectRes();
|
|
|
- int i = RandomUtil.randomInt(0, fm.size());
|
|
|
- String domain = fm.get(i).domain();
|
|
|
- String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
|
|
|
- domainSelectRes.setDomain(string+"."+domain);
|
|
|
- domainSelectRes.setPath("");
|
|
|
- domainSelectRes.setUnique(IdUtil.fastSimpleUUID());
|
|
|
- return Mono.just(domainSelectRes);
|
|
|
- });
|
|
|
- return RStatus.success(domainSelectResMono1);
|
|
|
+ String idKey = RedisKey.DOMAIN_RAND_ID + ":" + planInfo.groupId().toString() + ":" + type.toString();
|
|
|
+ String domainId = stringRedisTemplate.opsForSet().randomMember(idKey);
|
|
|
+ if (domainId == null || domainId.isEmpty()){
|
|
|
+ throw new BaseException("缓存"+ idKey + "不存在");
|
|
|
+ }
|
|
|
+ Object domainInfoCache = stringRedisTemplate.opsForHash().get(RedisKey.DOMAIN_INFO,domainId);
|
|
|
+ if (domainInfoCache == null){
|
|
|
+ throw new BaseException("缓存" + RedisKey.DOMAIN_INFO + "指定域名信息不存在");
|
|
|
+ }
|
|
|
+ DomainSelect domainInfo = com.alibaba.fastjson.JSONObject.parseObject(domainInfoCache.toString(),DomainSelect.class);
|
|
|
+ DomainSelectRes domainSelectRes = new DomainSelectRes();
|
|
|
+ String domain = domainInfo.domain();
|
|
|
+ String string = RandomUtil.randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6);
|
|
|
+ domainSelectRes.setDomain(string+"."+domain);
|
|
|
+ domainSelectRes.setPath("");
|
|
|
+ domainSelectRes.setUnique(IdUtil.fastSimpleUUID());
|
|
|
+ return RStatus.success(Mono.just(domainSelectRes));
|
|
|
}
|
|
|
throw new BaseException("typePlan 类型错误");
|
|
|
|