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);
                        }
                );
    }
原文地址:https://www.cnblogs.com/ukzq/p/13925771.html