Skip to content

Commit

Permalink
Mapper fix (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitolo-Andrea authored Oct 23, 2024
1 parent 7d693e6 commit 3aed12c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public Mono<CitizenConsentDTO> createCitizenConsent(CitizenConsentDTO citizenCon
citizenConsent.setCreationDate(LocalDateTime.now());
citizenConsent.setLastUpdateDate(LocalDateTime.now());
log.info("[EMD-CITIZEN][CREATE] Received consent: {}",inputSanify(citizenConsent.toString()));
return citizenRepository.findById(hashedFiscalCode)
return citizenRepository.findByHashedFiscalCodeAndTppId(hashedFiscalCode,citizenConsent.getTppId())
.flatMap(existingConsent -> {
log.info("[EMD][CREATE-CITIZEN-CONSENT] Citizen consent already exists");
return Mono.just(mapperToDTO.map(existingConsent));
})
.switchIfEmpty(
citizenRepository.save(citizenConsent)
.doOnSuccess(savedConsent -> log.info("[EMD][CREATE-CITIZEN-CONSENT] Created new citizen consent"))
.flatMap(savedConsent -> Mono.just(mapperToDTO.map(savedConsent))) // Map the saved consent
.flatMap(savedConsent -> Mono.just(mapperToDTO.map(savedConsent)))
);
}

Expand Down

0 comments on commit 3aed12c

Please sign in to comment.