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);
}
);
}