webflux 与 r2dbc repository(较)标准格式
public Mono<GroupsCountDMO> saveOrUpdateGroupsCount(GroupsCountDMO groupsCountDMO) {
log.info("groupsCountDMO:{}", groupsCountDMO);
return groupsCountRepository.findByChatIdAndAndWhichDay(groupsCountDMO.getChatId(), groupsCountDMO.getWhichDay())
.switchIfEmpty(
groupsCountRepository.save(groupsCountDMO.setAsNew())
)
.doOnSuccess(find -> log.info("findByChatIdAndAndWhichDay:{}", find))
.publishOn(Schedulers.boundedElastic())
.doOnError(e -> log.error("saveOrUpdateGroupsCount error:{}", e))
.flatMap(countEntity -> {
groupsCountDMO.setNewGroupsCount(false);
groupsCountDMO.setId(countEntity.getId());
return groupsCountRepository.updateAllCount(
groupsCountDMO.getChatId(),
groupsCountDMO.getWhichDay(),
groupsCountDMO.getUserAllCount());
}
)
.onErrorResume(
err -> {
log.error("GroupsCountDao saveGroupAllCount error :{}", err);
return Mono.error(err);
}
);
}
本文来自博客园,作者:ukyo--君君小时候,转载请注明原文链接:https://www.cnblogs.com/ukzq/p/13925771.html