From 167cfab4d2d97624f1f303f74cb499381822da98 Mon Sep 17 00:00:00 2001 From: flaminiaScarciofolo <113031535+flaminiaScarciofolo@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:05:20 +0100 Subject: [PATCH] [SELC-6087] Fix: findMailUuidAndUpdateUserRegistry method to retrieve workContact id (#235) --- apps/user-ms/src/main/docs/openapi.json | 2 +- apps/user-ms/src/main/docs/openapi.yaml | 2 +- .../it/pagopa/selfcare/user/mapper/UserMapper.java | 10 +++++++++- .../pagopa/selfcare/user/model/UpdateUserRequest.java | 2 +- .../selfcare/user/service/UserRegistryServiceImpl.java | 7 ++++--- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/user-ms/src/main/docs/openapi.json b/apps/user-ms/src/main/docs/openapi.json index ca69cf80..0ffc9925 100644 --- a/apps/user-ms/src/main/docs/openapi.json +++ b/apps/user-ms/src/main/docs/openapi.json @@ -1632,7 +1632,7 @@ "type" : "string" }, "mobilePhone" : { - "pattern" : "^\\+?[0-9]{9,15}$", + "pattern" : "^\\+?[0-9]{7,15}$", "type" : "string" } } diff --git a/apps/user-ms/src/main/docs/openapi.yaml b/apps/user-ms/src/main/docs/openapi.yaml index 822e1c46..3394b481 100644 --- a/apps/user-ms/src/main/docs/openapi.yaml +++ b/apps/user-ms/src/main/docs/openapi.yaml @@ -1191,7 +1191,7 @@ components: email: type: string mobilePhone: - pattern: "^\\+?[0-9]{9,15}$" + pattern: "^\\+?[0-9]{7,15}$" type: string User: required: diff --git a/apps/user-ms/src/main/java/it/pagopa/selfcare/user/mapper/UserMapper.java b/apps/user-ms/src/main/java/it/pagopa/selfcare/user/mapper/UserMapper.java index 1b359957..15f08a0e 100644 --- a/apps/user-ms/src/main/java/it/pagopa/selfcare/user/mapper/UserMapper.java +++ b/apps/user-ms/src/main/java/it/pagopa/selfcare/user/mapper/UserMapper.java @@ -16,7 +16,15 @@ import org.mapstruct.Mapping; import org.mapstruct.Named; import org.mapstruct.factory.Mappers; -import org.openapi.quarkus.user_registry_json.model.*; +import org.openapi.quarkus.user_registry_json.model.BirthDateCertifiableSchema; +import org.openapi.quarkus.user_registry_json.model.EmailCertifiableSchema; +import org.openapi.quarkus.user_registry_json.model.FamilyNameCertifiableSchema; +import org.openapi.quarkus.user_registry_json.model.MobilePhoneCertifiableSchema; +import org.openapi.quarkus.user_registry_json.model.MutableUserFieldsDto; +import org.openapi.quarkus.user_registry_json.model.NameCertifiableSchema; +import org.openapi.quarkus.user_registry_json.model.SaveUserDto; +import org.openapi.quarkus.user_registry_json.model.UserResource; +import org.openapi.quarkus.user_registry_json.model.WorkContactResource; import java.time.LocalDate; import java.util.*; diff --git a/apps/user-ms/src/main/java/it/pagopa/selfcare/user/model/UpdateUserRequest.java b/apps/user-ms/src/main/java/it/pagopa/selfcare/user/model/UpdateUserRequest.java index 3b167150..a9381996 100644 --- a/apps/user-ms/src/main/java/it/pagopa/selfcare/user/model/UpdateUserRequest.java +++ b/apps/user-ms/src/main/java/it/pagopa/selfcare/user/model/UpdateUserRequest.java @@ -9,6 +9,6 @@ public class UpdateUserRequest { private String name; private String familyName; private String email; - @Pattern(regexp = "^\\+?[0-9]{9,15}$", message = "Il numero di telefono non è valido") + @Pattern(regexp = "^\\+?[0-9]{7,15}$", message = "Il numero di telefono non è valido") private String mobilePhone; } diff --git a/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserRegistryServiceImpl.java b/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserRegistryServiceImpl.java index ad141d0c..13485f30 100644 --- a/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserRegistryServiceImpl.java +++ b/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserRegistryServiceImpl.java @@ -139,11 +139,12 @@ private Uni findMailUuidAndUpdateUserRegistry(UserResource userResource, .filter(stringWorkContactResourceEntry -> existsWorkContactResourceForPhoneAndMail(stringWorkContactResourceEntry, emailToCompare, mobilePhoneToCompare)) .findFirst() .map(Map.Entry::getKey)) - .orElse(null); + .orElse(idContacts); + return updateUsingPATCH(userResource.getId().toString(), - userMapper.toMutableUserFieldsDto(userDto, userResource, idContacts)) - .replaceWith(StringUtils.isBlank(existedUserMailUuid) ? idContacts : existedUserMailUuid); + userMapper.toMutableUserFieldsDto(userDto, userResource, existedUserMailUuid)) + .replaceWith(existedUserMailUuid); } private static boolean existsWorkContactResourceForPhoneAndMail(Map.Entry stringWorkContactResourceEntry, String emailToCompare, String mobilePhoneToCompare) {