77yf77yf77yf
2021-11-27 19:42:26 +08:00
return valueOperations.set(regCodeKey, regCode, Duration.of(10, TimeUnit.MINUTES.toChronoUnit()))
.then(reactiveRedisTemplate.hasKey(regCodeObtainRecordKey)
.doOnSuccess(hasRecordKey ->
listOperations.leftPush(regCodeObtainRecordKey, current).doOnSuccess(x -> {
if (!hasRecordKey) {
reactiveRedisTemplate.expire(regCodeObtainRecordKey, Duration.of(30, TimeUnit.DAYS.toChronoUnit()))
.doOnSuccess(opeSucc -> {
if (opeSucc) {
EmailMessageType.REGISTER.send(Lists.newArrayList(email), Lists.newArrayList(regCode));
}
}).subscribe();
}
}).subscribe()
))
.map(r -> {
if (r) {
return ResponseVO.ResponseCodeMsgMapping.SENDREG_SUCC.getResponse().toJson();
} else {
return ResponseVO.ResponseCodeMsgMapping.SYS_ERROR.getResponse().toJson();
}
});
想了想改了之后是这样的
但是还是有个问题,最后我要将整个流程完成与否的结果转化为 Mono<String>,但是如果像这样在最后 map 的话应该只是对 hasKey 的结果进行转化,有没有什么办法以最后整个流程完成的结果来转化