Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(关系): 优化固定值的判断 #313

Merged
merged 8 commits into from
Jun 6, 2023
Next Next commit
fix(阿里云短信): 解决短信模板和标签只能查询第一页数据问题 (#258)
  • Loading branch information
bestfeng1020 authored Apr 7, 2023
commit 7e5b898a7fdced9c30fbc7cdf9c6efa1f475d58d
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
import reactor.core.scheduler.Schedulers;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;

@Slf4j
Expand Down Expand Up @@ -164,24 +167,49 @@ public Mono<AliyunSmsExpansion> getSmsExpansion() {
* @return 短信签名集合
*/
public Flux<SmsSign> getSmsSigns() {
return Mono
.fromCallable(() -> client.getAcsResponse(new QuerySmsSignListRequest()))
.flatMapIterable(QuerySmsSignListResponse::getSmsSignList)
return doQuerySmsSigns(new AtomicInteger(0), 50)
.flatMapIterable(Function.identity())
.map(SmsSign::of)
.as(FluxTracer.create("/aliyun/sms/sign"))
.onErrorResume(err -> Mono.empty());
}

/**
* @return 短信模板集合
*/


public Flux<SmsTemplate> getSmsTemplates() {
return Mono
.fromCallable(() -> client.getAcsResponse(new QuerySmsTemplateListRequest()))
.flatMapIterable(QuerySmsTemplateListResponse::getSmsTemplateList)
return doQuerySmsTemplates(new AtomicInteger(0), 50)
.flatMapIterable(Function.identity())
.map(SmsTemplate::of)
.as(FluxTracer.create("/aliyun/sms/template"))
.onErrorResume(err -> Mono.empty());
}


public Flux<List<QuerySmsSignListResponse.QuerySmsSignDTO>> doQuerySmsSigns(AtomicInteger pageIndex, int pageSize) {
QuerySmsSignListRequest request = new QuerySmsSignListRequest();
request.setPageSize(pageSize);
request.setPageIndex(pageIndex.incrementAndGet());
return Mono
.fromCallable(() -> client.getAcsResponse(request).getSmsSignList())
.expand(dtos -> {
if (dtos.size() == pageSize){
return doQuerySmsSigns(pageIndex, pageSize);
}
return Flux.empty();
});
}

public Flux<List<QuerySmsTemplateListResponse.SmsStatsResultDTO>> doQuerySmsTemplates(AtomicInteger pageIndex, int pageSize) {
QuerySmsTemplateListRequest request = new QuerySmsTemplateListRequest();
request.setPageSize(pageSize);
request.setPageIndex(pageIndex.incrementAndGet());
return Mono
.fromCallable(() -> client.getAcsResponse(request).getSmsTemplateList())
.expand(dtos -> {
if (dtos.size() == pageSize){
return doQuerySmsTemplates(pageIndex, pageSize);
}
return Flux.empty();
});
}
}