Я хочу спросить о Webflux, используя Spring-data-mongoreactive. как вы выполняете проверку данных существуют? Я искал 3 дня, но до сих пор не нашел пути.
public Mono<TenantRegistrationModel> registration(TenantRegistrationModel registrationModel1) {
registrationModel1.beforeRegistration();
return Mono.just(registrationModel1).flatMap(registrationModel -> {
TenantEntity tenantEntity = new TenantEntity();
tenantEntity.setFullName(registrationModel.getFullName());
tenantEntity.setEmail(registrationModel.getEmail());
tenantEntity.setCountry(registrationModel.getCountry());
tenantEntity.setCity(registrationModel.getCity());
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
tenantEntity.setPassword(passwordEncoder.encode(registrationModel.getPassword()));
tenantEntity.setUpdatedAt(new Date());
tenantEntity.setCreatedAt(new Date());
Mono<TenantEntity> tenantEntityMono = this.tenantService.save(tenantEntity);
return this.tenantRepository.findByEmail(registrationModel.getEmail()).next().doOnNext(tenantEntity1 -> {
if (tenantEntity1.getEmail() != null)
throw new ApiExceptionUtils("email already eixst", HttpStatus.UNPROCESSABLE_ENTITY.value(), StatusCodeUtils.VALIDATION_FAIL);
}).switchIfEmpty(tenantEntityMono).map(tenantEntity1 -> {
registrationModel.setId(tenantEntity1.getId());
return registrationModel;
});
});
}
Я хочу проверить 2 запроса из mongoreactive и сравнить результат.