|
|
@@ -26,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
|
|
import org.springframework.data.redis.core.ReactiveRedisTemplate;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.data.relational.core.query.Criteria;
|
|
|
import org.springframework.data.relational.core.query.Query;
|
|
|
@@ -56,7 +57,9 @@ public class PlanNewCommonOutController {
|
|
|
@Resource
|
|
|
private GoGenerateService goGenerateService;
|
|
|
@Resource
|
|
|
- private ReactiveRedisTemplate<String, Object> reactiveRedisTemplate;
|
|
|
+ private ReactiveRedisTemplate<String, String> reactiveRedisTemplate;
|
|
|
+ @Resource
|
|
|
+ private RedisTemplate<String, String> redisTemplate;
|
|
|
@Resource
|
|
|
private IpAnalyzeServiceInterface ipAnalyzeServiceInterface;
|
|
|
private static final ConcurrentHashMap<String, Integer> MAP = new ConcurrentHashMap<>();
|
|
|
@@ -464,19 +467,24 @@ public class PlanNewCommonOutController {
|
|
|
if (Objects.isNull(id) || id <= 0) {
|
|
|
return Mono.just(getAudio());
|
|
|
}
|
|
|
+ return template.selectOne(Query.query(Criteria.where("id").is(id)), Audio.class)
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划retAudioId:{}查询音频为空", id))))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException(StrUtil.format("通过计划retAudioId:{}查询音频Error::", id, throwable.getMessage()))));
|
|
|
+ // String value = redisTemplate.opsForValue().get(RedisKey.FISSION_AUDIO + id);
|
|
|
// 优先读缓存
|
|
|
- Mono<Object> obj = reactiveRedisTemplate.opsForValue().get(RedisKey.FISSION_AUDIO + id)
|
|
|
- .switchIfEmpty(Mono.just(" "));
|
|
|
- return obj.flatMap(val -> {
|
|
|
- if (val != null && StrUtil.isNotBlank(val.toString())) {
|
|
|
- Audio audio = JSON.parseObject(val.toString(), Audio.class);
|
|
|
- return Mono.just(audio);
|
|
|
- } else {
|
|
|
- return template.selectOne(Query.query(Criteria.where("id").is(id)), Audio.class)
|
|
|
- .switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划retAudioId:{}查询音频为空", id))))
|
|
|
- .onErrorResume(throwable -> Mono.error(new BaseException(StrUtil.format("通过计划retAudioId:{}查询音频Error::", id, throwable.getMessage()))));
|
|
|
- }
|
|
|
- });
|
|
|
+ // Mono<String> obj = reactiveRedisTemplate.opsForValue().get(RedisKey.FISSION_AUDIO + id)
|
|
|
+ // .switchIfEmpty(Mono.just(" "))
|
|
|
+ // .onErrorResume(throwable -> Mono.error(new BaseException(StrUtil.format("通过计划retAudioId:{}查询音频Error::", id, throwable.getMessage()))));
|
|
|
+ // return obj.flatMap(val -> {
|
|
|
+ // if (val != null && StrUtil.isNotBlank(val.toString())) {
|
|
|
+ // Audio audio = JSON.parseObject(val.toString(), Audio.class);
|
|
|
+ // return Mono.just(audio);
|
|
|
+ // } else {
|
|
|
+ // return template.selectOne(Query.query(Criteria.where("id").is(id)), Audio.class)
|
|
|
+ // .switchIfEmpty(Mono.error(new BaseException(StrUtil.format("通过计划retAudioId:{}查询音频为空", id))))
|
|
|
+ // .onErrorResume(throwable -> Mono.error(new BaseException(StrUtil.format("通过计划retAudioId:{}查询音频Error::", id, throwable.getMessage()))));
|
|
|
+ // }
|
|
|
+ // });
|
|
|
}
|
|
|
|
|
|
private Audio getAudio() {
|