diff --git a/src/main/java/com/billpaymentservice/bbps/dto/BillerDTO.java b/src/main/java/com/billpaymentservice/bbps/dto/BillerDTO.java index 005b1d2..99af937 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/BillerDTO.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/BillerDTO.java @@ -2,6 +2,7 @@ package com.billpaymentservice.bbps.dto; import java.util.List; +import com.billpaymentservice.bbps.entites.AdditionalInfoBillValidate; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import jakarta.validation.constraints.NotBlank; @@ -102,7 +103,7 @@ public class BillerDTO { private BillerResponseParamsDTO billerResponseParams; private List billerAdditionalInfos; - private List billerAdditionalInfoPayments; + private List billerAdditionalInfoPayments; private List interchangeFeeConves; private List interchangeFees; diff --git a/src/main/java/com/billpaymentservice/bbps/dto/response/FetchBillValidateResponse.java b/src/main/java/com/billpaymentservice/bbps/dto/response/FetchBillValidateResponse.java index 471b13b..4593f61 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/response/FetchBillValidateResponse.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/response/FetchBillValidateResponse.java @@ -19,7 +19,6 @@ import lombok.ToString; @NoArgsConstructor @ToString public class FetchBillValidateResponse { - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private GeneralResp genericResponse; private String billId; diff --git a/src/main/java/com/billpaymentservice/bbps/entites/BillValidation.java b/src/main/java/com/billpaymentservice/bbps/entites/BillValidation.java index b620411..d4a01dd 100644 --- a/src/main/java/com/billpaymentservice/bbps/entites/BillValidation.java +++ b/src/main/java/com/billpaymentservice/bbps/entites/BillValidation.java @@ -37,8 +37,8 @@ public class BillValidation { @Column(name = "biller_response", columnDefinition = "TEXT") private String billerResponse; - @Column(name = "additional_info", columnDefinition = "TEXT") - private String additionalInfo; + @OneToMany(mappedBy = "bill", cascade = CascadeType.ALL, fetch = FetchType.LAZY) + private List additionalInfo; // 👇 Proper nested customer params (OneToMany) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "bill") diff --git a/src/main/java/com/billpaymentservice/bbps/entites/BillerAdditionalInfoPayment.java b/src/main/java/com/billpaymentservice/bbps/entites/BillerAdditionalInfoPayment.java index 5411901..5599c1b 100644 --- a/src/main/java/com/billpaymentservice/bbps/entites/BillerAdditionalInfoPayment.java +++ b/src/main/java/com/billpaymentservice/bbps/entites/BillerAdditionalInfoPayment.java @@ -13,7 +13,7 @@ import lombok.Getter; import lombok.Setter; @Getter @Setter -@Table(name = "biller_additional_additional_info_payment") +@Table(name = "biller_additional_info_payment") @Entity public class BillerAdditionalInfoPayment { @Id diff --git a/src/main/java/com/billpaymentservice/bbps/entites/BillerDetails.java b/src/main/java/com/billpaymentservice/bbps/entites/BillerDetails.java index 63b08fd..24f4511 100644 --- a/src/main/java/com/billpaymentservice/bbps/entites/BillerDetails.java +++ b/src/main/java/com/billpaymentservice/bbps/entites/BillerDetails.java @@ -29,7 +29,8 @@ import lombok.ToString; "billerAdditionalInfos", "interchangeFeeConves", "interchangeFees", - "billerPlanResponseParams" + "billerPlanResponseParams", + "billerAdditionalInfoPayments" }) @Table(name = "biller_details") @@ -151,11 +152,9 @@ public class BillerDetails { @OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true) private List billerAdditionalInfos; - - /* - * OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval - * =true) private List billerAdditionalInfoPayments; - */ + @OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval=true) + private List billerAdditionalInfoPayments; + @OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true) private List interchangeFeeConves; diff --git a/src/main/java/com/billpaymentservice/bbps/serviceImpl/MasterDataServiceImpl.java b/src/main/java/com/billpaymentservice/bbps/serviceImpl/MasterDataServiceImpl.java index 87da985..b322de8 100644 --- a/src/main/java/com/billpaymentservice/bbps/serviceImpl/MasterDataServiceImpl.java +++ b/src/main/java/com/billpaymentservice/bbps/serviceImpl/MasterDataServiceImpl.java @@ -194,7 +194,7 @@ public class MasterDataServiceImpl implements MasterDataService { mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); BillerDetails entity = mapper.map(responseWrapper.getBillerDAO(), BillerDetails.class); EntityRelationshipUtil.linkBillerRelationships(entity);// linking nesting entity foreign key - //helper.saveOrUpdateBillerData(entity); + helper.saveOrUpdateBillerData(entity); ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()), responseWrapper); helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); diff --git a/src/main/java/com/billpaymentservice/bbps/util/EntityRelationshipUtil.java b/src/main/java/com/billpaymentservice/bbps/util/EntityRelationshipUtil.java index b7b24c3..caec51d 100644 --- a/src/main/java/com/billpaymentservice/bbps/util/EntityRelationshipUtil.java +++ b/src/main/java/com/billpaymentservice/bbps/util/EntityRelationshipUtil.java @@ -37,6 +37,10 @@ public class EntityRelationshipUtil { entity.getBillerAdditionalInfos().forEach(a -> a.setBiller(entity)); } + if(entity.getBillerAdditionalInfoPayments() != null) { + entity.getBillerAdditionalInfoPayments().forEach(a -> a.setBiller(entity)); + } + if (entity.getInterchangeFees() != null) { for (InterchangeFee fee : entity.getInterchangeFees()) { diff --git a/src/main/java/com/billpaymentservice/bbps/util/Helper.java b/src/main/java/com/billpaymentservice/bbps/util/Helper.java index 379ba40..a73ca30 100644 --- a/src/main/java/com/billpaymentservice/bbps/util/Helper.java +++ b/src/main/java/com/billpaymentservice/bbps/util/Helper.java @@ -26,6 +26,7 @@ import com.billpaymentservice.bbps.dto.sentRequest.BillPaymentForwardRequest; import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest; import com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest; import com.billpaymentservice.bbps.entites.AdditionalInfoBill; +import com.billpaymentservice.bbps.entites.AdditionalInfoBillValidate; import com.billpaymentservice.bbps.entites.BBPSMastersData; import com.billpaymentservice.bbps.entites.BillMaster; import com.billpaymentservice.bbps.entites.BillValidation; @@ -218,32 +219,7 @@ public class Helper { Optional existingOpt = billerDataRespository.findByBillerId(newEntity.getBillerId()); if (existingOpt.isPresent()) { - BillerDetails existing = existingOpt.get(); - - // Update base biller fields - existing.setBillerName(newEntity.getBillerName()); - existing.setBillerAliasName(newEntity.getBillerAliasName()); - existing.setBillerDescription(newEntity.getBillerDescription()); - existing.setStatus(newEntity.getStatus()); - existing.setBillerCoverage(newEntity.getBillerCoverage()); - // ... (update other simple fields as needed) - - // ✅ Clear and replace nested lists to avoid duplicate inserts - existing.getBillerPaymentModes().clear(); - if (newEntity.getBillerPaymentModes() != null) { - for (PaymentMode mode : newEntity.getBillerPaymentModes()) { - mode.setBiller(existing); - existing.getBillerPaymentModes().add(mode); - } - } - existing.getBillerPaymentChannels().clear(); - if (newEntity.getBillerPaymentChannels() != null) { - for (PaymentChannel channel : newEntity.getBillerPaymentChannels()) { - channel.setBiller(existing); - existing.getBillerPaymentChannels().add(channel); - } - } - billerDataRespository.save(existing); + //logic to be written } else { // brand new biller @@ -348,7 +324,18 @@ billMasterRepository.save(billMaster); .collect(Collectors.toList()); billEntity.setCustomerParams(customerParams); } - + if (responseWrapper.getAdditionalInfo() != null) { + List additionalInfos = responseWrapper.getAdditionalInfo() + .stream() + .map(info -> { + AdditionalInfoBillValidate ai = modelMapper.map(info, AdditionalInfoBillValidate.class); + ai.setBill(billEntity); // maintain relation + return ai; + }) + .collect(Collectors.toList()); + billEntity.setAdditionalInfo(additionalInfos); + + } // ✅ Save everything (cascade handles child) billValidationRepository.save(billEntity);