cretaed entities for BillerDetail

This commit is contained in:
himanshu
2025-10-31 10:10:43 +05:30
parent 65cd50567d
commit 6ec6847ad2
31 changed files with 413 additions and 61 deletions
@@ -10,7 +10,7 @@ public class BbpsApplication {
public static void main(String[] args) {
SpringApplication.run(BbpsApplication.class, args);
}
}
@@ -0,0 +1,19 @@
package com.billpaymentservice.bbps.dto;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class AdditionalInfoDTO {
@NotBlank(message = "Param Config ID cannot be blank")
private String paramConfigId;
@NotBlank(message = "Param name cannot be blank")
private String paramName;
private String dataTypeDAO;
private String dataTypeModel;
private boolean optional;
private boolean visibility;
}
@@ -0,0 +1,12 @@
package com.billpaymentservice.bbps.dto;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class AmountOptionDTO{
private String amountOptionId; // Matches "amountOptionId" from JSON
private List<String> amountBreakupSets; // Reference to BillerResponseParams (only ID, not full entity)
}
@@ -0,0 +1,109 @@
package com.billpaymentservice.bbps.dto;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class BillerDTO {
@NotBlank(message = "Biller ID is mandatory")
@Size(min = 14, max = 14, message = "Biller ID must be 14 characters long")
private String billerId;
@NotBlank(message = "Biller name cannot be blank")
private String billerName;
@NotBlank(message = "Biller alias name cannot be blank")
private String billerAliasName;
@NotBlank(message = "Biller category name cannot be blank")
private String billerCategoryName;
@NotBlank(message = "Biller mode cannot be blank")
private String billerMode;
private boolean billerAcceptsAdhoc;
private boolean parentBiller;
@NotBlank(message = "Parent biller ID cannot be blank")
private String parentBillerId;
@NotBlank(message = "Biller ownership is required (PSU or Private)")
private String billerOwnerShp;
@NotBlank(message = "Biller coverage cannot be blank")
private String billerCoverage;
@NotBlank(message = "Fetch requirement is mandatory")
private String fetchRequirement;
@NotBlank(message = "Payment amount exactness is required")
private String paymentAmountExactness;
@NotBlank(message = "Support bill validation is required")
private String supportBillValidation;
@NotBlank(message = "Effective from date is required")
private String billerEffctvFrom;
@NotBlank(message = "Effective to date is required")
private String billerEffctvTo;
private String billerTempDeactivationStart;
private String billerTempDeactivationEnd;
@NotBlank(message = "Biller description cannot be blank")
private String billerDescription;
@NotBlank(message = "Biller response type is required (SINGLE or SELECTIVE)")
private String billerResponseType;
@NotBlank(message = "Plan MDM requirement cannot be blank")
private String planMDMRequirement;
@NotBlank(message = "Status must be ACTIVE or INACTIVE")
private String status;
@NotBlank(message = "Support deemed value is required (Yes/No)")
private String supportDeemed;
@NotBlank(message = "Support pending status is required (Yes/No)")
private String supportPendingStatus;
@NotBlank(message = "Biller timeout is required")
private String billerTimeOut;
private String routeUrl;
private String upmsEnabled;
private String clickpayEnabled;
private String deemedSuccessEnabled;
private String selectionType;
// ✅ Nested lists and objects — matching API structure
private List<PaymentModeDTO> billerPaymentModes;
private List<PaymentChannelDTO> billerPaymentChannels;
private List<CustomerParamDTO> billerCustomerParams;
private CustomerParamGroupsDTO customerParamGroups;
private BillerResponseParamsDTO billerResponseParams;
private List<AdditionalInfoDTO> billerAdditionalInfos;
private List<AdditionalInfoDTO> billerAdditionalInfoPayments;
private List<InterchangeFeeConfDTO> interchangeFeeConves;
private List<InterchangeFeeDTO> interchangeFees;
private BillerPlanResponseParamsDTO billerPlanResponseParams;
}
@@ -0,0 +1,14 @@
package com.billpaymentservice.bbps.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class BillerPlanResponseParamsDTO {
private String billerPlanResponseId;
private String paramsJson;
private String amountOptionsJson;
}
@@ -0,0 +1,15 @@
package com.billpaymentservice.bbps.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class BillerResponseParamsDTO {
private String billerResponseId;
private List<String> params;
private List<AmountOptionDTO> amountOptions;
}
@@ -0,0 +1,28 @@
package com.billpaymentservice.bbps.dto;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class CustomerParamDTO {
private String paramConfigId;
@NotBlank(message = "Parameter name is required")
private String paramName;
private String dataTypeDAO;
private String dataTypeModel;
private boolean optional;
@Min(0)
private int minLength;
@Min(0)
private int maxLength;
private String regex;
private boolean visibility;
// ✅ List of possible values
private List<String> values;
}
@@ -0,0 +1,10 @@
package com.billpaymentservice.bbps.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class CustomerParamGroupsDTO {
private List<GroupDTO> groups;
}
@@ -0,0 +1,19 @@
package com.billpaymentservice.bbps.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class GroupDTO {
private String name;
private String input;
private List<String> params;
// 🔁 Nested child groups
private List<GroupDTO> groups;
}
@@ -0,0 +1,27 @@
package com.billpaymentservice.bbps.dto;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class InterchangeFeeConfDTO {
@NotBlank(message = "Interchange Fee Config ID cannot be blank")
private String interChangeFeeConfId;
private String mti;
private String paymentMode;
private String paymentChannel;
private String responseCode;
private List<String> fees;
private boolean defaultFee;
private String effctvFrom;
private String effctvTo;
}
@@ -0,0 +1,26 @@
package com.billpaymentservice.bbps.dto;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class InterchangeFeeDTO {
@NotBlank(message = "Interchange Fee ID cannot be blank")
private String interchangeFeeId;
@NotBlank(message = "Fee code is mandatory")
private String feeCode;
private String feeDesc;
private String feeDirection;
// ✅ One-to-Many relation represented by DTO list
private List<InterchangeFeeDetailDTO> interchangeFeeDetails;
}
@@ -0,0 +1,23 @@
package com.billpaymentservice.bbps.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class InterchangeFeeDetailDTO {
private String interchangeFeeDetId;
private long tranAmtRangeMax;
private long tranAmtRangeMin;
private double percentFee;
private double flatFee;
private String effctvFrom;
}
@@ -0,0 +1,27 @@
package com.billpaymentservice.bbps.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class PaymentChannelDTO {
private String paymentChannelLimitId;
@NotBlank(message = "Payment channel is required")
private String paymentChannel;
@Min(value = 0, message = "Max limit cannot be negative")
private long maxLimit;
@Min(value = 0, message = "Min limit cannot be negative")
private long minLimit;
private String supportPendingStatus;
}
@@ -0,0 +1,28 @@
package com.billpaymentservice.bbps.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.validation.constraints.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class PaymentModeDTO {
@NotBlank(message = "Payment model limit ID cannot be blank")
private String paymentModelLimitId;
@NotBlank(message = "Payment mode is mandatory")
private String paymentMode;
@PositiveOrZero(message = "Max limit must be zero or positive")
private long maxLimit;
@PositiveOrZero(message = "Min limit must be zero or positive")
private long minLimit;
@Pattern(regexp = "^(Yes|No)?$", message = "Support pending status must be either 'Yes' or 'No'")
private String supportPendingStatus;
}
@@ -1,8 +1,8 @@
package com.billpaymentservice.bbps.dto.response;
import com.billpaymentservice.bbps.dto.BillerDAO;
import com.billpaymentservice.bbps.dto.BillerDTO;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -13,7 +13,7 @@ import lombok.Setter;
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class BillerDataResponse {
private BillerDAO billerDAO;
private BillerDTO billerDAO;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private GeneralResp generalResp;
}
@@ -4,8 +4,8 @@ import java.util.List;
import com.billpaymentservice.bbps.dto.ContactMaster;
import com.billpaymentservice.bbps.dto.CustomParam;
import com.billpaymentservice.bbps.dto.CustomerParam;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.billpaymentservice.bbps.entites.CustomerParam;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.*;
@@ -39,5 +39,5 @@ public class AdditionalInfo {
// 🔗 Many AdditionalInfos belong to one Biller
@ManyToOne
@JoinColumn(name = "biller_id", nullable = false)
private BillerDAO biller;
private BillerDetails biller;
}
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.*;
@@ -6,6 +6,8 @@ import lombok.Getter;
import lombok.Setter;
import java.util.List;
import com.billpaymentservice.bbps.entites.BillerResponseParams;
@Entity
@Table(name = "amount_option")
@Getter
@@ -1,9 +1,11 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
@@ -11,9 +13,10 @@ import java.util.List;
@Getter
@Setter
@Entity
@ToString
@Table(name = "biller_details")
@JsonIgnoreProperties(ignoreUnknown = true)
public class BillerDAO {
public class BillerDetails {
@Id
@Column(name = "biller_id", length = 14, nullable = false, unique = true)
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import java.util.List;
@@ -35,6 +35,6 @@ public class BillerPlanResponseParams {
// 🔗 Relationship with BillerDAO
@OneToOne
@JoinColumn(name = "biller_id", nullable = false)
private BillerDAO biller;
private BillerDetails biller;
}
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.*;
@@ -21,7 +21,7 @@ public class BillerResponseParams {
// 🔗 One-to-One Relationship with BillerDAO
@OneToOne
@JoinColumn(name = "biller_id", nullable = false)
private BillerDAO biller;
private BillerDetails biller;
// ✅ Since params and amountOptions are lists of objects,
// we can store them as JSON or in a separate table (simplified here using @ElementCollection)
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
@@ -54,5 +54,5 @@ public class CustomerParam {
// 🔗 Many customer parameters belong to one biller
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "biller_id")
private BillerDAO biller;
private BillerDetails biller;
}
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.*;
import lombok.Getter;
@@ -20,7 +20,7 @@ public class CustomerParamGroups {
// 🔗 One set of groups belongs to one biller
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "biller_id")
private BillerDAO biller;
private BillerDetails biller;
// 🔗 One CustomerParamGroups contains multiple Group objects
@OneToMany(mappedBy = "customerParamGroups", cascade = CascadeType.ALL, orphanRemoval = true)
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.*;
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import java.util.List;
@@ -43,5 +43,5 @@ public class InterchangeFee {
// 🔗 Many InterchangeFee entries belong to one Biller
@ManyToOne
@JoinColumn(name = "biller_id", nullable = false)
private BillerDAO biller;
private BillerDetails biller;
}
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import java.util.List;
@@ -59,5 +59,5 @@ public class InterchangeFeeConf {
// 🔗 Many InterchangeFeeConf records belong to one Biller
@ManyToOne
@JoinColumn(name = "biller_id", nullable = false)
private BillerDAO biller;
private BillerDetails biller;
}
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.*;
import lombok.Getter;
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
@@ -35,5 +35,5 @@ public class PaymentChannel {
// 🔗 Many PaymentChannels belong to one Biller
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "biller_id")
private BillerDAO biller;
private BillerDetails biller;
}
@@ -1,4 +1,4 @@
package com.billpaymentservice.bbps.dto;
package com.billpaymentservice.bbps.entites;
@@ -40,6 +40,6 @@ public class PaymentMode {
// 🔗 Many-to-One relationship with BillerDAO
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "biller_id", nullable = false)
private BillerDAO biller;
private BillerDetails biller;
}
@@ -3,32 +3,13 @@ package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.dto.BillerDAO;
import com.billpaymentservice.bbps.entites.BillerDetails;
import java.util.List;
@Repository
public interface BillerDataRepository extends JpaRepository<BillerDAO, String> {
public interface BillerDataRepository extends JpaRepository<BillerDetails, String> {
// ✅ Custom finder methods
// Find billers by category name
List<BillerDAO> findByBillerCategoryName(String billerCategoryName);
// Find all active billers
List<BillerDAO> findByStatus(String status);
// Find billers by alias name
BillerDAO findByBillerAliasName(String billerAliasName);
// Find billers by parent biller ID
List<BillerDAO> findByParentBillerId(String parentBillerId);
// Check if a biller exists by name
boolean existsByBillerName(String billerName);
// Fetch biller by mode (e.g., ONLINE, OFFLINE)
List<BillerDAO> findByBillerMode(String billerMode);
// Fetch biller by ownership (PSU / PRIVATE)
List<BillerDAO> findByBillerOwnerShp(String billerOwnerShp);
}
@@ -6,6 +6,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -13,7 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import com.billpaymentservice.bbps.dto.BillerDAO;
import com.billpaymentservice.bbps.dto.BillerDTO;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.billpaymentservice.bbps.dto.MasterApiResponse;
import com.billpaymentservice.bbps.dto.ResponseModel;
@@ -28,6 +30,8 @@ import com.billpaymentservice.bbps.dto.response.CategoryResponse;
import com.billpaymentservice.bbps.dto.response.ContactMasterResponse;
import com.billpaymentservice.bbps.dto.response.CustomParamResp;
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
import com.billpaymentservice.bbps.entites.BillPayment;
import com.billpaymentservice.bbps.entites.BillerDetails;
import com.billpaymentservice.bbps.exception.AppException;
import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.BillerDataRepository;
@@ -99,16 +103,21 @@ public class MasterDataServiceImpl implements MasterDataService {
}
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
BillerDAO biller = responseWrapper.getBillerDAO();
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
BillerDetails entity = mapper.map(responseWrapper.getBillerDAO(), BillerDetails.class);
if (biller != null) {
LOGGER.info("Saving biller {} to database...", biller.getBillerId());
billerDataRespository.save(biller);
} else {
LOGGER.warn("No biller found in response to save.");
}
System.out.println(entity);
if (entity != null)
{
billerDataRespository.save(entity);
}
else {
LOGGER.warn("No biller found in response to save.");
}
ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),