improved code quality and tested with test data

This commit is contained in:
Lincpay Tech
2025-11-23 23:33:47 +05:30
parent 135947cfd6
commit d46d084654
8 changed files with 29 additions and 39 deletions
@@ -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<AdditionalInfoDTO> billerAdditionalInfos;
private List<AdditionalInfoDTO> billerAdditionalInfoPayments;
private List<BillerAdditonalInfoDTO> billerAdditionalInfoPayments;
private List<InterchangeFeeConfDTO> interchangeFeeConves;
private List<InterchangeFeeDTO> interchangeFees;
@@ -19,7 +19,6 @@ import lombok.ToString;
@NoArgsConstructor
@ToString
public class FetchBillValidateResponse {
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private GeneralResp genericResponse;
private String billId;
@@ -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<AdditionalInfoBillValidate> additionalInfo;
// 👇 Proper nested customer params (OneToMany)
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "bill")
@@ -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
@@ -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<AdditionalInfo> billerAdditionalInfos;
/*
* OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval
* =true) private List<AdditionalInfo> billerAdditionalInfoPayments;
*/
@OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval=true)
private List<BillerAdditionalInfoPayment> billerAdditionalInfoPayments;
@OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true)
private List<InterchangeFeeConf> interchangeFeeConves;
@@ -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());
@@ -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()) {
@@ -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<BillerDetails> 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<AdditionalInfoBillValidate> 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);