From 41e16ec4075fd1147024a1922d59efc1def00c05 Mon Sep 17 00:00:00 2001 From: Raja Nabeel Date: Tue, 14 May 2024 12:16:49 +0500 Subject: [PATCH] commit multiple instances and email based account inquiry implemented --- .../com/mfsys/uco/constants/UCOConstants.java | 6 ++++++ .../repository/CustomerProfileRepository.java | 3 ++- .../mfsys/uco/service/UcoAccountService.java | 19 ++++++++++++------- 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/mfsys/uco/constants/UCOConstants.java diff --git a/src/main/java/com/mfsys/uco/constants/UCOConstants.java b/src/main/java/com/mfsys/uco/constants/UCOConstants.java new file mode 100644 index 0000000..e51232b --- /dev/null +++ b/src/main/java/com/mfsys/uco/constants/UCOConstants.java @@ -0,0 +1,6 @@ +package com.mfsys.uco.constants; + +public interface UCOConstants { + String CMP_PHONE = "01"; + String CMP_EMAIL = "02"; +} diff --git a/src/main/java/com/mfsys/uco/repository/CustomerProfileRepository.java b/src/main/java/com/mfsys/uco/repository/CustomerProfileRepository.java index 016e816..845d490 100644 --- a/src/main/java/com/mfsys/uco/repository/CustomerProfileRepository.java +++ b/src/main/java/com/mfsys/uco/repository/CustomerProfileRepository.java @@ -10,7 +10,8 @@ import org.springframework.stereotype.Repository; public interface CustomerProfileRepository extends JpaRepository { @Query("SELECT c FROM BN_CS_MP_CUSTOMERPROFILE c WHERE c.porOrgacode =:porOrgacode and c.padAdrsmobphone = :phone") CustomerProfile findProfilesByMobilePhone(String porOrgacode, String phone); - + @Query("SELECT c FROM BN_CS_MP_CUSTOMERPROFILE c WHERE c.porOrgacode =:porOrgacode and c.cmpEmail = :cmpEmail") + CustomerProfile findCustomerProfileByCmpEmailAndPorOrgacode(String porOrgacode, String cmpEmail); @Query("SELECT c FROM BN_CS_MP_CUSTOMERPROFILE c WHERE c.porOrgacode =:porOrgacode and c.cmpEmail = :email") CustomerProfile findbyEmail(String porOrgacode, String email); } diff --git a/src/main/java/com/mfsys/uco/service/UcoAccountService.java b/src/main/java/com/mfsys/uco/service/UcoAccountService.java index f219940..2e46e4c 100644 --- a/src/main/java/com/mfsys/uco/service/UcoAccountService.java +++ b/src/main/java/com/mfsys/uco/service/UcoAccountService.java @@ -1,6 +1,7 @@ package com.mfsys.uco.service; import com.fasterxml.jackson.databind.ObjectMapper; +import com.mfsys.uco.constants.UCOConstants; import com.mfsys.uco.constants.UCOURI; import com.mfsys.uco.dto.AccountInquiryResponse; import com.mfsys.uco.dto.SignupStep3RequestModel; @@ -20,6 +21,7 @@ import java.util.Map; import java.util.Objects; + @Service public class UcoAccountService { @@ -39,15 +41,18 @@ public class UcoAccountService { } public AccountInquiryResponse fetchAccountTitile(String porOrgacode, String acntTypeCode, String acntTypeValue) { - if (acntTypeCode.equals("01")) { - CustomerProfile customerProfile = customerProfileRepository.findProfilesByMobilePhone(porOrgacode, acntTypeValue); - if (Objects.isNull(customerProfile)) { + CustomerProfile customerProfile = new CustomerProfile(); + + if (acntTypeCode.equals(UCOConstants.CMP_PHONE)) { + customerProfile = customerProfileRepository.findProfilesByMobilePhone(porOrgacode, acntTypeValue); + } else if (acntTypeCode.equals(UCOConstants.CMP_EMAIL)) { + customerProfile = customerProfileRepository.findCustomerProfileByCmpEmailAndPorOrgacode(porOrgacode, acntTypeValue); + } + if (Objects.isNull(customerProfile)) { throw new AccountDoesntExistsException(); - } - UcoAccount ucoAccount = ucoAccountRepository.findUcoAccountByCmpCustcode(porOrgacode, customerProfile.getCmpCustcode()); - return AccountInquiryResponse.builder().mbmBkmsnumber(ucoAccount.getId().getMbmBkmsnumber()).mbmBkmstitle(ucoAccount.getMbmBkmstitle()).build(); } - return null; + UcoAccount ucoAccount = ucoAccountRepository.findUcoAccountByCmpCustcode(porOrgacode, customerProfile.getCmpCustcode()); + return AccountInquiryResponse.builder().mbmBkmsnumber(ucoAccount.getId().getMbmBkmsnumber()).mbmBkmstitle(ucoAccount.getMbmBkmstitle()).build(); }