added seprate auditable in entity

This commit is contained in:
Lincpay Tech
2025-12-09 10:13:23 +05:30
parent 1cfe331ff1
commit 2c4855d59a
77 changed files with 495 additions and 489 deletions
@@ -1,42 +0,0 @@
package com.billpaymentservice.bbps.audit;
import java.io.Serializable;
import java.util.Date;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import lombok.Data;
@Data
@MappedSuperclass
public abstract class Auditable<U> implements Serializable {
private static final long serialVersionUID = 1L;
@CreatedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "create_date_time")
protected Date createDateTime;
@LastModifiedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updated_date_time")
protected Date updatedDateTime;
@LastModifiedBy
@Column(name = "updated_by")
protected U updatedBy;
@CreatedBy
@Column(name = "create_by")
protected U createdBy;
@Column(name = "is_deleted")
protected boolean isDeleted = false;
}
@@ -15,7 +15,7 @@ import lombok.Setter;
@Table(name = "additional_info_bill")
@Getter
@Setter
public class AdditionalInfoBill {
public class AdditionalInfoBill extends Auditable {
@Id
@GeneratedValue
private Long id;
@@ -27,4 +27,4 @@ public class AdditionalInfoBill {
@JoinColumn(name = "bill_master_id")
private BillMaster billMaster;
}
}
@@ -14,7 +14,7 @@ import lombok.Setter;
@Table(name = "additional_info_bill_validate")
@Getter
@Setter
public class AdditionalInfoBillValidate {
public class AdditionalInfoBillValidate extends Auditable {
@Id
@GeneratedValue
private Long id;
@@ -26,4 +26,4 @@ public class AdditionalInfoBillValidate {
@JoinColumn(name = "bill_id_fk")
private BillValidation bill;
}
}
@@ -19,7 +19,7 @@ import lombok.Setter;
@Table(name = "plan_additional_info")
@Getter
@Setter
public class AdditionalInfoPlans {
public class AdditionalInfoPlans extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -30,4 +30,4 @@ public class AdditionalInfoPlans {
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "additionalInfo")
private List<PlanTag> tags;
}
}
@@ -15,7 +15,7 @@ import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
public class AgentFundTransfer {
public class AgentFundTransfer extends Auditable {
@Id
@@ -53,4 +53,4 @@ public class AgentFundTransfer {
@Column(name = "fund_status")
private String fundStatus;
}
}
@@ -14,7 +14,7 @@ import lombok.Setter;
@Getter
@Setter
@Table(name = "agent_fund_transfer")
public class AgentFundTransferEntity {
public class AgentFundTransferEntity extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -33,5 +33,4 @@ public class AgentFundTransferEntity {
private String agentNpciId;
private String txnRefId;
private String fundStatus;
}
}
@@ -19,7 +19,7 @@ import lombok.Setter;
@Table(name = "amount_option")
@Getter
@Setter
public class AmountOption {
public class AmountOption extends Auditable {
@Id
@Column(name = "amount_option_id")
@@ -2,8 +2,6 @@ package com.billpaymentservice.bbps.entites;
import java.util.List;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@@ -20,7 +18,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "amount_option_biller_id")
public class AmountOptionByBillerId extends Auditable<String> {
public class AmountOptionByBillerId extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -33,4 +31,4 @@ public class AmountOptionByBillerId extends Auditable<String> {
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "amount_option_id_long") // Foreign key field that links to the 'Long' column
private List<AmountOptionDetails> amountOptionDetails; // List of AmountOptionDetails
}
}
@@ -13,7 +13,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "amount_option_details")
public class AmountOptionDetails {
public class AmountOptionDetails extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -38,4 +38,4 @@ public class AmountOptionDetails {
@Column(name = "user_id")
private String userId;
}
}
@@ -0,0 +1,83 @@
package com.billpaymentservice.bbps.entites;
import java.lang.reflect.Field;
import java.time.LocalDateTime;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
/**
* Generic JPA entity listener that populates common audit fields on entities.
*
* Behavior:
* - On PrePersist: sets createdAt/creationDate/createdEpochDate if present (only when null),
* and forces isDeleted/deleted to false if those fields exist.
* - On PreUpdate: sets modifiedDate/modifiedEpochDate/updatedAt/updatedOn if present.
*
* This uses reflection so entities don't need to extend a specific base class.
*/
public class AuditListener {
@PrePersist
public void prePersist(Object entity) {
LocalDateTime now = LocalDateTime.now();
setIfNull(entity, "createdAt", now);
setIfNull(entity, "createdOn", now);
setIfNull(entity, "creationDate", now == null ? null : now.toString());
setIfNull(entity, "createdEpochDate", System.currentTimeMillis());
// Ensure isDeleted / deleted exists and is set to false on create
setAlways(entity, "isDeleted", Boolean.FALSE);
setAlways(entity, "deleted", Boolean.FALSE);
}
@PreUpdate
public void preUpdate(Object entity) {
LocalDateTime now = LocalDateTime.now();
setIfNull(entity, "modifiedDate", now == null ? null : now.toString());
setIfNull(entity, "modifiedEpochDate", System.currentTimeMillis());
setIfNull(entity, "updatedAt", now);
setIfNull(entity, "updatedOn", now);
}
private void setIfNull(Object entity, String fieldName, Object value) {
try {
Field f = findField(entity.getClass(), fieldName);
if (f == null) return;
boolean accessible = f.canAccess(entity);
f.setAccessible(true);
Object current = f.get(entity);
if (current == null && value != null) {
f.set(entity, value);
}
f.setAccessible(accessible);
} catch (Exception e) {
// ignore reflection failures
}
}
private void setAlways(Object entity, String fieldName, Object value) {
try {
Field f = findField(entity.getClass(), fieldName);
if (f == null) return;
boolean accessible = f.canAccess(entity);
f.setAccessible(true);
f.set(entity, value);
f.setAccessible(accessible);
} catch (Exception e) {
// ignore reflection failures
}
}
private Field findField(Class<?> cls, String name) {
Class<?> cur = cls;
while (cur != null && cur != Object.class) {
try {
return cur.getDeclaredField(name);
} catch (NoSuchFieldException e) {
cur = cur.getSuperclass();
}
}
return null;
}
}
@@ -0,0 +1,41 @@
package com.billpaymentservice.bbps.entites;
import java.time.LocalDateTime;
import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import lombok.Setter;
/**
* Base mapped superclass for audit fields. All JPA entities should extend this to
* get automatic population of createdAt/updatedAt/isDeleted via AuditListener.
*/
@MappedSuperclass
@EntityListeners(AuditListener.class)
@Getter
@Setter
public abstract class Auditable {
@Column(name = "created_at")
private LocalDateTime createdAt;
@Column(name = "updated_at")
private LocalDateTime updatedAt;
@Column(name = "created_on")
private LocalDateTime createdOn;
@Column(name = "updated_on")
private LocalDateTime updatedOn;
@Column(name = "created_epoch_date")
private Long createdEpochDate;
@Column(name = "modified_epoch_date")
private Long modifiedEpochDate;
@Column(name = "is_deleted")
private Boolean isDeleted = Boolean.FALSE;
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -21,7 +19,7 @@ import lombok.Setter;
@Getter
@Setter
@Table(name = "bbps_master_data")
public class BBPSMastersData extends Auditable<String> {
public class BBPSMastersData extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -43,4 +41,4 @@ public class BBPSMastersData extends Auditable<String> {
@Column(name = "user_name")
private String userName;
}
}
@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@Builder
@Table(name = "bbps_merchant_validation")
public class BBPSMerchantValidation {
public class BBPSMerchantValidation extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -42,5 +42,5 @@ public class BBPSMerchantValidation {
private String txtId;
private boolean is_deleted;
}
// Removed local is_deleted field, now handled by Auditable
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
@@ -18,7 +16,7 @@ import lombok.Setter;
@NoArgsConstructor
@Entity
@Table(name = "Bharat_connect_master")
public class BharatConnectMaster extends Auditable<String> {
public class BharatConnectMaster extends Auditable {
@Id
@Column(name = "org_id", nullable = false, unique = true, length = 50)
@@ -46,4 +44,4 @@ public class BharatConnectMaster extends Auditable<String> {
@Column(name = "is_active")
private boolean isActive=false;
}
}
@@ -14,7 +14,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "bill_additional_info")
public class BillAdditionalInfo {
public class BillAdditionalInfo extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -28,4 +28,4 @@ public class BillAdditionalInfo {
@JoinColumn(name = "biller_response_id")
private CheckClientBillerData billerResponse;
}
}
@@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@Entity
@Table(name = "bill_initiate")
public class BillInitiate {
public class BillInitiate extends Auditable {
@Id
@Column(name = "req_id")
private String reqId;
@@ -27,4 +27,4 @@ public class BillInitiate {
@Column(name = "client_user_id")
private String clientUserId;
}
}
@@ -23,7 +23,7 @@ import lombok.Setter;
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class BillMaster {
public class BillMaster extends Auditable {
@Id
private String billId; // primary key
@@ -43,10 +43,6 @@ public class BillMaster {
private List<AdditionalInfoBill> additionalInfo;
@OneToMany(mappedBy = "billMaster", cascade = CascadeType.ALL)
private List<CustomerParamBill> customerParams;
private String creationDate;
private String modifiedDate;
private Long createdEpochDate;
private Long modifiedEpochDate;
// getters and setters
}
}
@@ -1,6 +1,5 @@
package com.billpaymentservice.bbps.entites;
import java.time.LocalDateTime;
import java.util.List;
import jakarta.persistence.CascadeType;
@@ -17,7 +16,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "bill_payment")
public class BillPayment {
public class BillPayment extends Auditable {
@Id
@Column(name = "txn_id")
@@ -53,10 +52,7 @@ public class BillPayment {
@Column(name = "customer_mobile")
private String customerMobNo;
@Column(name = "created_at")
private LocalDateTime createdAt = LocalDateTime.now();
// 🔗 One bill payment has many remitter identities
@OneToMany(mappedBy = "billPayment", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
private List<RemitterIdentity> remitterIdentities;
}
}
@@ -14,7 +14,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "bill_tag_list")
public class BillTag {
public class BillTag extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -27,4 +27,4 @@ public class BillTag {
@JoinColumn(name = "biller_response_id")
private CheckClientBillerData billerResponse;
}
}
@@ -12,7 +12,7 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BillValidation {
public class BillValidation extends Auditable {
@Id
@Column(name = "bill_id", nullable = false, length = 100)
@@ -46,18 +46,6 @@ public class BillValidation {
@Column(name = "plan_info_daos", columnDefinition = "TEXT")
private String planInfoDaos;
@Column(name = "creation_date", length = 50)
private String creationDate;
@Column(name = "modified_date", length = 50)
private String modifiedDate;
@Column(name = "created_epoch_date", length = 50)
private String createdEpochDate;
@Column(name = "modified_epoch_date", length = 50)
private String modifiedEpochDate;
@Column(name = "txn_id")
private String txnId;
@@ -66,4 +54,7 @@ public class BillValidation {
@Column(name = "client_user_id")
private String clientUserId;
}
// Removed local audit fields: creationDate, modifiedDate, createdEpochDate, modifiedEpochDate
// They are now handled by Auditable base class
}
@@ -15,7 +15,7 @@ import lombok.Setter;
@Setter
@Table(name = "biller_additional_info_payment")
@Entity
public class BillerAdditionalInfoPayment {
public class BillerAdditionalInfoPayment extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; // primary key for the table
@@ -42,4 +42,4 @@ public class BillerAdditionalInfoPayment {
@ManyToOne
@JoinColumn(name = "biller_id", nullable = false)
private BillerDetails biller;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
@@ -23,7 +21,7 @@ import lombok.Setter;
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class BillerCategoryIcon extends Auditable<String>{
public class BillerCategoryIcon extends Auditable{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -42,4 +40,4 @@ public class BillerCategoryIcon extends Auditable<String>{
foreignKey = @ForeignKey(name = "fk_icon_biller"))
private BillerCategoryWise biller;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@@ -20,7 +18,7 @@ import lombok.Setter;
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class BillerCategoryWise extends Auditable<String> {
public class BillerCategoryWise extends Auditable {
@Id
@Column(name = "biller_id")
@@ -66,4 +64,4 @@ public class BillerCategoryWise extends Auditable<String> {
@OneToOne(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private BillerCategoryIcon icon;
}
}
@@ -2,12 +2,12 @@ package com.billpaymentservice.bbps.entites;
import java.util.List;
import com.billpaymentservice.bbps.audit.Auditable;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
@@ -21,6 +21,7 @@ import lombok.ToString;
@Getter
@Setter
@Entity
@EntityListeners(AuditListener.class)
@ToString(exclude = {
"billerPaymentModes",
"billerPaymentChannels",
@@ -36,7 +37,7 @@ import lombok.ToString;
@Table(name = "biller_details")
@JsonIgnoreProperties(ignoreUnknown = true)
public class BillerDetails{
public class BillerDetails extends Auditable {
@Id
@Column(name = "biller_id", length = 14, nullable = false, unique = true)
@@ -160,4 +161,4 @@ public class BillerDetails{
@OneToOne(mappedBy = "biller", cascade = CascadeType.ALL)
private BillerPlanResponseParams billerPlanResponseParams;
}
}
@@ -18,7 +18,7 @@ import lombok.ToString;
@Entity
@ToString
@Table(name = "biller_plan_response_params")
public class BillerPlanResponseParams {
public class BillerPlanResponseParams extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; // Primary Key
@@ -36,5 +36,4 @@ public class BillerPlanResponseParams {
@OneToOne
@JoinColumn(name = "biller_id", nullable = false)
private BillerDetails biller;
}
}
@@ -14,7 +14,7 @@ import lombok.Setter;
@Table(name = "biller_response")
@Getter
@Setter
public class BillerResponse {
public class BillerResponse extends Auditable {
@Id
@GeneratedValue
@@ -55,4 +55,4 @@ public class BillerResponse {
private BillMaster billMaster;
// getters and setters
}
}
@@ -21,7 +21,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "biller_response_params")
public class BillerResponseParams {
public class BillerResponseParams extends Auditable {
@Id
@Column(name = "biller_response_id", nullable = false, unique = true)
@@ -46,4 +46,4 @@ public class BillerResponseParams {
@OneToMany(mappedBy = "billerResponseParams", cascade = CascadeType.ALL, orphanRemoval = true)
private List<AmountOption> amountOptions;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -15,7 +13,7 @@ import lombok.Setter;
@Table(name = "category_response_list")
@Getter
@Setter
public class CategoryResponseList extends Auditable<String> {
public class CategoryResponseList extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -33,4 +31,4 @@ public class CategoryResponseList extends Auditable<String> {
@Column(name = "user_id")
private String userId;
}
}
@@ -19,7 +19,7 @@ import lombok.Setter;
@Table(name = "check_client_biller_data")
@Getter
@Setter
public class CheckClientBillerData {
public class CheckClientBillerData extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -65,4 +65,4 @@ public class CheckClientBillerData {
@OneToMany(mappedBy = "billerResponse", cascade = CascadeType.ALL)
private List<BillCustomerParams> customerParams;
}
}
@@ -13,7 +13,7 @@ import lombok.Setter;
@Table(name = "check_client_status_req_id")
@Getter
@Setter
public class CheckClientStatusReqId {
public class CheckClientStatusReqId extends Auditable {
@Id
@Column(name = "bill_id", length = 200)
@@ -34,18 +34,6 @@ public class CheckClientStatusReqId {
@Column(name = "user_id")
private String userId;
@Column(name = "creation_date")
private String creationDate;
@Column(name = "modified_date")
private String modifiedDate;
@Column(name = "created_epoch_date")
private Long createdEpochDate;
@Column(name = "modified_epoch_date")
private Long modifiedEpochDate;
@Column(name = "req_id")
private String reqId;
@@ -57,4 +45,4 @@ public class CheckClientStatusReqId {
private CheckClientBillerData billerResponse;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -17,7 +15,7 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CloseComplaint extends Auditable<String> {
public class CloseComplaint extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -104,4 +102,4 @@ public class CloseComplaint extends Auditable<String> {
@Column(name = "system_txn_id")
private String systemTxnId;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -15,7 +13,7 @@ import lombok.Setter;
@Table(name = "complaint_status")
@Getter
@Setter
public class ComplainStatus extends Auditable<String> {
public class ComplainStatus extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -71,4 +69,4 @@ public class ComplainStatus extends Auditable<String> {
@Column(name = "user_id")
private String userId;
}
}
@@ -9,7 +9,7 @@ import lombok.ToString;
@Getter
@Setter
@ToString
public class ComplaintDetails {
public class ComplaintDetails extends Auditable {
@Id
@Column(name = "complaint_id", nullable = false, unique = true)
@@ -68,4 +68,4 @@ public class ComplaintDetails {
@Column(name = "modified_epoch_date")
private Long modifiedEpochDate;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -19,7 +17,7 @@ import lombok.Setter;
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ComplaintHistory extends Auditable<String> {
public class ComplaintHistory extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -46,4 +44,4 @@ public class ComplaintHistory extends Auditable<String> {
@Column(name = "user_id")
private String userId;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -17,7 +15,7 @@ import lombok.ToString;
@Setter
@ToString
@Table(name = "complaint_responses")
public class ComplaintResponseEntity extends Auditable<String> {
public class ComplaintResponseEntity extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@@ -68,4 +66,4 @@ public class ComplaintResponseEntity extends Auditable<String> {
@Column(name = "user_id")
private String userId;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -15,7 +13,7 @@ import lombok.Setter;
@Getter
@Setter
@Table(name = "view_ticket_status")
public class ComplaintStatusDetails extends Auditable<String> {
public class ComplaintStatusDetails extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -87,4 +85,4 @@ public class ComplaintStatusDetails extends Auditable<String> {
@Column(name = "biller_name")
private String billerName;
}
}
@@ -15,7 +15,7 @@ import lombok.ToString;
@Getter
@Setter
@ToString
public class ComplaintStatusOptionsMaster {
public class ComplaintStatusOptionsMaster extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -24,7 +24,5 @@ public class ComplaintStatusOptionsMaster {
@Column(name = "status_label_name")
private String statusLabelName;
@Column(name = "is_deleted")
private Boolean isDeleted = false;
}
// Removed local isDeleted field, now handled by Auditable
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -19,7 +17,7 @@ import lombok.Setter;
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ContactMasterData extends Auditable<String> {
public class ContactMasterData extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -36,4 +34,4 @@ public class ContactMasterData extends Auditable<String> {
@Column(name = "user_id")
private String userId;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -17,7 +15,7 @@ import lombok.ToString;
@Entity
@ToString
@Table(name = "custom_param")
public class CustomParam extends Auditable<String> {
public class CustomParam extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -53,4 +51,4 @@ public class CustomParam extends Auditable<String> {
@Column(name = "user_id")
private String userId;
}
}
@@ -24,7 +24,7 @@ import lombok.ToString;
@Entity
@Table(name = "customer_param")
@ToString
public class CustomerParam {
public class CustomerParam extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -68,4 +68,4 @@ public class CustomerParam {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "biller_id")
private BillerDetails biller;
}
}
@@ -13,7 +13,7 @@ import lombok.Setter;
@Getter
@Setter
@Table(name = "customer_param_bill")
public class CustomerParamBill {
public class CustomerParamBill extends Auditable {
@Id
@GeneratedValue
@@ -28,4 +28,4 @@ public class CustomerParamBill {
private BillMaster billMaster;
// getters and setters
}
}
@@ -10,7 +10,7 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CustomerParamBillValidation {
public class CustomerParamBillValidation extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -30,4 +30,4 @@ public class CustomerParamBillValidation {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "bill_id_fk")
private BillValidation bill;
}
}
@@ -13,7 +13,7 @@ import lombok.Setter;
@Getter
@Setter
@Table(name = "customer_params")
public class CustomerParamDAO {
public class CustomerParamDAO extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -2,8 +2,6 @@ package com.billpaymentservice.bbps.entites;
import java.util.List;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@@ -21,7 +19,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "customer_param_group_by_biller_id")
public class CustomerParamGroupById extends Auditable<String> {
public class CustomerParamGroupById extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -58,4 +56,4 @@ public class CustomerParamGroupById extends Auditable<String> {
@Column(name = "user_id")
private String userId;
}
}
@@ -22,7 +22,7 @@ import lombok.ToString;
@Entity
@ToString
@Table(name = "customer_param_groups")
public class CustomerParamGroups {
public class CustomerParamGroups extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -37,5 +37,4 @@ public class CustomerParamGroups {
// 🔗 One CustomerParamGroups contains multiple Group objects
@OneToMany(mappedBy = "customerParamGroups", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Group> groups;
}
}
@@ -15,7 +15,7 @@ import lombok.Setter;
@Getter
@Setter
@Table(name = "customer_params_transaction")
public class CustomerParamTransaction {
public class CustomerParamTransaction extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -29,5 +29,4 @@ public class CustomerParamTransaction {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "txn_id", referencedColumnName = "bank_txn_id")
private TransactionMaster transactionMaster;
}
}
@@ -16,7 +16,7 @@ import lombok.Setter;
@Getter
@Setter
@Table(name = "device_block_tag")
public class DeviceBlockTag {
public class DeviceBlockTag extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -35,4 +35,4 @@ public class DeviceBlockTag {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "txn_id", referencedColumnName = "bank_txn_id")
private TransactionMaster transactionMaster;
}
}
@@ -13,7 +13,7 @@ import lombok.ToString;
@Entity
@Table(name = "disposition_details")
@ToString
public class DispositionDetails {
public class DispositionDetails extends Auditable {
@Id
@Column(name = "disposition_id", nullable = false, unique = true)
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -19,7 +17,7 @@ import lombok.Setter;
@NoArgsConstructor
@Entity
@Table(name = "fetch_bill_validate_response")
public class FetchBillValidate extends Auditable<String> {
public class FetchBillValidate extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -63,10 +61,10 @@ public class FetchBillValidate extends Auditable<String> {
private String modifiedDate;
@Column(name = "created_epoch_date")
private long createdEpochDate;
private Long createdEpochDate;
@Column(name = "modified_epoch_date")
private long modifiedEpochDate;
private Long modifiedEpochDate;
@Column(name = "request_id")
private String requestId;
@@ -74,4 +72,4 @@ public class FetchBillValidate extends Auditable<String> {
@Column(name = "txn_id")
private String txnId;
}
}
@@ -26,7 +26,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "biller_groups")
public class Group {
public class Group extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -59,4 +59,4 @@ public class Group {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "group_container_id")
private CustomerParamGroups customerParamGroups;
}
}
@@ -15,7 +15,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "group_params")
public class GroupParam {
public class GroupParam extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -28,4 +28,4 @@ public class GroupParam {
@JoinColumn(name = "group_id")
private CustomerParamGroupById group; // Link to the group this parameter belongs to
}
}
@@ -22,7 +22,7 @@ import lombok.ToString;
@Entity
@ToString
@Table(name = "interchange_fee")
public class InterchangeFee {
public class InterchangeFee extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -48,4 +48,4 @@ public class InterchangeFee {
@ManyToOne
@JoinColumn(name = "biller_id", nullable = false)
private BillerDetails biller;
}
}
@@ -20,7 +20,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "interchange_fee_conf")
public class InterchangeFeeConf {
public class InterchangeFeeConf extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -63,4 +63,4 @@ public class InterchangeFeeConf {
@ManyToOne
@JoinColumn(name = "biller_id", nullable = false)
private BillerDetails biller;
}
}
@@ -15,7 +15,7 @@ import lombok.Setter;
@Table(name = "interchange_fee_detail")
@Getter
@Setter
public class InterchangeFeeDetail {
public class InterchangeFeeDetail extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -43,4 +43,4 @@ public class InterchangeFeeDetail {
@ManyToOne
@JoinColumn(name = "interchange_fee_id", nullable = false)
private InterchangeFee interchangeFee;
}
}
@@ -18,7 +18,7 @@ import lombok.ToString;
@Entity
@ToString
@Table(name = "payment_channel")
public class PaymentChannel {
public class PaymentChannel extends Auditable {
@Id
@Column(name = "payment_channel_limit_id")
@@ -42,4 +42,4 @@ public class PaymentChannel {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "biller_id")
private BillerDetails biller;
}
}
@@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@Entity
@Table(name = "payment_initiate")
public class PaymentInitiate {
public class PaymentInitiate extends Auditable {
@Id
@Column(name = "req_id")
@@ -36,4 +36,4 @@ public class PaymentInitiate {
@Column(name = "user_id")
private String userId;
}
}
@@ -21,7 +21,7 @@ import lombok.ToString;
@Entity
@Table(name = "biller_payment_modes")
@ToString
public class PaymentMode {
public class PaymentMode extends Auditable {
@Id //
@@ -46,5 +46,4 @@ public class PaymentMode {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "biller_id", nullable = false)
private BillerDetails biller;
}
}
@@ -18,7 +18,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@Entity
@Table(name = "payment_start_record")
public class PaymentStartRecord {
public class PaymentStartRecord extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -50,9 +50,10 @@ public class PaymentStartRecord {
@Column(name = "qr_string", columnDefinition = "TEXT")
private String qrString;
@Column(name = "created_on", nullable = false)
private String createdOn;
// `createdOn` is provided by the base `Auditable` class as a LocalDateTime field,
// so we must not redeclare it here (it caused an incompatible return-type error).
// The Auditable base class already defines `createdOn` of type LocalDateTime.
// New callback-related fields
@Column(name = "callback_status")
private String callbackStatus;
@@ -21,7 +21,7 @@ import lombok.Setter;
@Table(name = "plan")
@Getter
@Setter
public class Plan {
public class Plan extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -62,4 +62,4 @@ public class Plan {
@JoinColumn(name = "additional_info_id", referencedColumnName = "id")
private AdditionalInfoPlans additionalInfo;
}
}
@@ -15,7 +15,7 @@ import lombok.Setter;
@Table(name = "plan_category_sub_type")
@Getter
@Setter
public class PlanCategorySubType {
public class PlanCategorySubType extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -27,4 +27,4 @@ public class PlanCategorySubType {
@JoinColumn(name = "plan_id")
private Plan plan;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@@ -19,7 +17,7 @@ import lombok.Setter;
@Table(name = "plan_response")
@Getter
@Setter
public class PlanResponses extends Auditable<String> {
public class PlanResponses extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -50,4 +48,4 @@ public class PlanResponses extends Auditable<String> {
@Column(name = "user_id")
private String userId;
}
}
@@ -8,7 +8,7 @@ import lombok.Setter;
@Table(name = "plan_tag")
@Getter
@Setter
public class PlanTag {
public class PlanTag extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -30,4 +30,4 @@ public class PlanTag {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "additional_info_id", referencedColumnName = "id")
private AdditionalInfoPlans additionalInfo;
}
}
@@ -17,7 +17,7 @@ import lombok.Setter;
@Table(name = "plans_list")
@Getter
@Setter
public class PlansList {
public class PlansList extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -26,4 +26,4 @@ public class PlansList {
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "plansList")
private List<Plan> plans;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -15,7 +13,7 @@ import lombok.Setter;
@Table(name = "reopen_complaint")
@Getter
@Setter
public class ReOpenComplain extends Auditable<String> {
public class ReOpenComplain extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -92,10 +90,10 @@ public class ReOpenComplain extends Auditable<String> {
private String category;
@Column(name = "created_epoch_date")
private long createdEpochDate;
private Long createdEpochDate;
@Column(name = "modified_epoch_date")
private long modifiedEpochDate;
private Long modifiedEpochDate;
@Column(name = "req_id")
private String reqId;
@@ -103,4 +101,4 @@ public class ReOpenComplain extends Auditable<String> {
@Column(name = "system_txn_id")
private String systemTxnId;
}
}
@@ -16,7 +16,7 @@ import lombok.Setter;
@Setter
@Entity
@Table(name = "remitter_identity")
public class RemitterIdentity {
public class RemitterIdentity extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -33,4 +33,4 @@ public class RemitterIdentity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "txn_id")
private BillPayment billPayment;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -17,7 +15,7 @@ import lombok.ToString;
@Entity
@Table(name = "ticket_disposition_details")
@ToString
public class TicketDispositionDetails extends Auditable<String> {
public class TicketDispositionDetails extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -43,4 +41,4 @@ public class TicketDispositionDetails extends Auditable<String> {
@Column(name = "user_id")
private String userId;
}
}
@@ -24,7 +24,7 @@ import lombok.ToString;
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class TransactionMaster {
public class TransactionMaster extends Auditable {
// 👇 JSON me "txn_id" aayega, ye DB me bank_txn_id column me save hoga
@Id
@@ -166,4 +166,4 @@ public class TransactionMaster {
@Column(name = "modified_epoch_date")
private Long modifiedEpochDate;
}
}
@@ -1,5 +1,5 @@
package com.billpaymentservice.bbps.entites;
public class TxnStatus {
public class TxnStatus extends Auditable {
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -19,7 +17,7 @@ import lombok.Setter;
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class UserEntity extends Auditable<String> {
public class UserEntity extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -1,6 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -16,7 +15,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@Entity
@Table(name = "user_details")
public class UsersDetails extends Auditable<String> {
public class UsersDetails extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -35,4 +34,4 @@ public class UsersDetails extends Auditable<String> {
@Column(name = "user_age")
private String userAge;
}
}
@@ -1,7 +1,5 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
@@ -15,7 +13,7 @@ import lombok.Setter;
@Getter
@Setter
@Table(name = "view_all_complaint_ticket_status")
public class ViewAllComplaintTicketStatusDetails extends Auditable<String> {
public class ViewAllComplaintTicketStatusDetails extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -86,4 +84,4 @@ public class ViewAllComplaintTicketStatusDetails extends Auditable<String> {
@Column(name = "biller_name")
private String billerName;
}
}
@@ -1,7 +1,6 @@
package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
@@ -9,6 +8,6 @@ import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
@Repository
public interface MerchantRepository extends JpaRepository<BBPSMerchantValidation, Long> {
@Query("from BBPSMerchantValidation where mid = ?1 and is_deleted = false")
public BBPSMerchantValidation findByMid(String mid);
}
// Use Spring Data derived query to filter by entity property `isDeleted` (handled by Auditable)
BBPSMerchantValidation findByMidAndIsDeletedFalse(String mid);
}
@@ -220,7 +220,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
// mapperHelper.saveOrUpdateBillerData(entity);
mapperHelper.saveOrUpdateBillerData(entity);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
@@ -214,7 +214,6 @@ public class BillerMapperHelper {
biller.setPlanMDMRequirement(dto.getPlanMDMRequirement());
biller.setAdhocBiller(dto.getAdhocBiller());
biller.setPaymentAmountExactness(dto.getPaymentAmountExactness());
biller.setCreateDateTime(new Date());
biller.setRequestId(requestId);
biller.setTxnId(txnId);
biller.setUserId(userId);
@@ -279,7 +278,6 @@ public class BillerMapperHelper {
groupEntity.setRequestId(requestId);
groupEntity.setTxnId(txnId);
groupEntity.setUserId(userId);
groupEntity.setCreateDateTime(new Date());
// Save group parameters (if any)
if (groupDTO.getParams() != null && !groupDTO.getParams().isEmpty()) {
List<GroupParam> groupParams = new ArrayList<>();
@@ -367,7 +365,6 @@ public class BillerMapperHelper {
List<AmountOptionDetails> amountOptionDetailsList = mapAmountOptionDTOToEntity(
responseWrapper.getAmountOptionDAOS(), requestId, txnId, userId);
entity.setAmountOptionDetails(amountOptionDetailsList);
entity.setCreateDateTime(new Date());
amountOptionByBillerIdRepository.save(entity); // Saves the entity and cascades to AmountOptionDetails
@@ -416,7 +413,6 @@ public class BillerMapperHelper {
response.setTotalPages(planResponse.getTotalPages());
response.setTxnId(txnId);
response.setUserId(userId);
response.setCreateDateTime(new Date());
PlansList plansList = new PlansList();
List<Plan> planEntities = new ArrayList<>();
@@ -489,7 +485,6 @@ public class BillerMapperHelper {
category.setCategoryRespList(item);
category.setRequestId(txnId);
category.setRequestId(requestId);
category.setCreateDateTime(new Date());
category.setUserId(userId);
categoryResponseListRepository.save(category);
savedCount++;
@@ -536,7 +531,6 @@ public class BillerMapperHelper {
entity.setNpciTicketType(dto.getNpciTicketType());
entity.setNpciTicketStatus(dto.getNpciTicketStatus());
entity.setCreatedTime(dto.getCreatedTime());
entity.setCreateDateTime(new Date());
entity.setUserId(userId);
try {
@@ -567,7 +561,6 @@ public class BillerMapperHelper {
entity.setHistoryStatus(dto.getHistoryStatus());
entity.setReqId(reqId);
entity.setTxnId(txnId);
entity.setCreateDateTime(new Date());
entity.setUserId(userId);
complaintHistoryRepository.save(entity);
@@ -683,7 +676,6 @@ public class BillerMapperHelper {
entity.setTotalElements(String.valueOf(responseWrapper.getTotalElements()));
entity.setPage(String.valueOf(responseWrapper.getPage()));
entity.setPageSize(String.valueOf(responseWrapper.getPageSize()));
entity.setCreateDateTime(new Date());
entity.setUserId(userId);
}
@@ -726,8 +718,11 @@ public class BillerMapperHelper {
parent.setStatus(responseWrapper.getStatus());
parent.setActionType(responseWrapper.getActionType());
parent.setUserId(responseWrapper.getUserId());
parent.setCreationDate(responseWrapper.getCreationDate());
parent.setModifiedDate(responseWrapper.getModifiedDate());
// Map incoming DTO date strings into Auditable LocalDateTime fields
LocalDateTime parentCreatedOn = parseToLocalDateTime(responseWrapper.getCreationDate());
if (parentCreatedOn != null) parent.setCreatedOn(parentCreatedOn);
LocalDateTime parentUpdatedOn = parseToLocalDateTime(responseWrapper.getModifiedDate());
if (parentUpdatedOn != null) parent.setUpdatedOn(parentUpdatedOn);
parent.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
parent.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
parent.setReqId(reqId);
@@ -828,7 +823,6 @@ public class BillerMapperHelper {
entity.setDispositionCode(dto.getDispositionCode());
// Set current datetime
entity.setCreateDateTime(new Date());
entity.setTxnId(txnId);
entity.setReqId(requestId);
entity.setUserId(userId);
@@ -862,7 +856,6 @@ public class BillerMapperHelper {
entity.setPageSize(String.valueOf(responseWrapper.getPageSize()));
entity.setTotalPages(String.valueOf(responseWrapper.getTotalPages()));
entity.setTotalElements(String.valueOf(responseWrapper.getTotalElements()));
entity.setCreateDateTime(new Date());
entity.setUserId(userId);
}
@@ -887,7 +880,6 @@ public class BillerMapperHelper {
entity.setReqId(requestId);
entity.setTxnId(txnID);
entity.setUserId(userId);
entity.setCreateDateTime(new Date());
return entity;
}).collect(Collectors.toList());
@@ -926,7 +918,7 @@ public class BillerMapperHelper {
billMaster.setUserId(userId);
billMaster.setClientUserId(billFetchByBillIdRequest.getClientUserId());
// BILLER RESPONSE
// BILLER RESPONSE
BillerResponse billerResponse = new BillerResponse();
if (responseWrapper.getBillerResponse() != null) {
billerResponse.setBillId(responseWrapper.getBillerResponse().getBillId());
@@ -943,7 +935,7 @@ public class BillerMapperHelper {
}
billMaster.setBillerResponse(billerResponse);
// ADDITIONAL INFO
// ADDITIONAL INFO
List<AdditionalInfoBill> additionalInfos = new ArrayList<>();
if (responseWrapper.getAdditionalInfo() != null) {
for (AdditionalInfoBillDTO info : responseWrapper.getAdditionalInfo()) {
@@ -956,7 +948,7 @@ public class BillerMapperHelper {
}
billMaster.setAdditionalInfo(additionalInfos);
// CUSTOMER PARAMS
// CUSTOMER PARAMS
List<CustomerParamBill> customerParams = new ArrayList<>();
if (responseWrapper.getCustomerParams() != null) {
for (CustomerParamDAO param : responseWrapper.getCustomerParams()) {
@@ -970,170 +962,45 @@ public class BillerMapperHelper {
}
billMaster.setCustomerParams(customerParams);
// DATES
billMaster.setCreationDate(responseWrapper.getCreationDate());
billMaster.setModifiedDate(responseWrapper.getModifiedDate());
// DATES
// Map incoming DTO date strings into Auditable LocalDateTime fields
LocalDateTime bmCreatedOn = parseToLocalDateTime(responseWrapper.getCreationDate());
if (bmCreatedOn != null) {
billMaster.setCreatedOn(bmCreatedOn);
}
LocalDateTime bmUpdatedOn = parseToLocalDateTime(responseWrapper.getModifiedDate());
if (bmUpdatedOn != null) {
billMaster.setUpdatedOn(bmUpdatedOn);
}
billMaster.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
billMaster.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
billMasterRepository.save(billMaster);
}
public void saveBillValidation(FetchBillValidateResponse responseWrapper, BillFetchByBillIdRequest billRequest,
String txnId) {
System.out.println("responseWrapper");
ModelMapper modelMapper = new ModelMapper();
try {
LOGGER.info("Saving bill validation data for billId={}", responseWrapper.getBillId());
// ✅ Map the main object
BillValidation billEntity = modelMapper.map(responseWrapper, BillValidation.class);
// ✅ Manually handle only the nested relationship part
if (responseWrapper.getCustomerParams() != null) {
List<CustomerParamBillValidation> customerParams = responseWrapper.getCustomerParams().stream()
.map(param -> {
CustomerParamBillValidation cp = modelMapper.map(param, CustomerParamBillValidation.class);
cp.setBill(billEntity); // maintain relation
return cp;
}).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);
billEntity.setClientUserId(billRequest.getClientUserId());
billEntity.setTxnId(txnId);
billEntity.setRefId(billRequest.getReqId());
}
// ✅ Save everything (cascade handles child)
billValidationRepository.save(billEntity);
LOGGER.info("Bill validation saved successfully for billId={}", billEntity.getBillId());
} catch (Exception ex) {
LOGGER.error("Error saving BillValidation data: {}", ex.getMessage(), ex);
throw new RuntimeException("Failed to save bill validation data", ex);
}
}
public FetchBillForwardRequest fetchBillForwardRequestMap(FetchBillRequest req) {
FetchBillForwardRequest forward = new FetchBillForwardRequest();
forward.setBillerId(req.getBillerId());
forward.setBillerName(req.getBillerName());
forward.setBillerCategory(req.getBillerCategory());
forward.setClientReqId(req.getClientReqId());
forward.setMacAdress(req.getMacAdress());
forward.setCustomerMobNo(req.getCustomerMobNo());
forward.setRemitterName(req.getRemitterName());
forward.setPaymentChannel(req.getPaymentChannel());
forward.setDeviceBlockTags(req.getDeviceBlockTags());
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
forward.setRemitterIdentity(req.getRemitterIdentity());
return forward;
}
public FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(FetchBillValidatestRequest req) {
FetchBillValidatestForwardRequest forward = new FetchBillValidatestForwardRequest();
forward.setBillerId(req.getBillerId());
forward.setBillerName(req.getBillerName());
forward.setBillerCategory(req.getBillerCategory());
forward.setCustomerMobNo(req.getCustomerMobNo());
forward.setClientReqId(req.getClientReqId());
forward.setMacAddress(req.getMacAddress());
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
return forward;
}
public BillPaymentForwardRequest billPaymentForwardRequest(BillPaymentRequest req) {
BillPaymentForwardRequest forward = new BillPaymentForwardRequest();
// forward.setTenantId(req.getTenantId());
forward.setRefId(req.getRefId());
forward.setBillId(req.getBillId());
forward.setAmountOptions(req.isAmountOptions());
forward.setPaymentMode(req.getPaymentMode());
forward.setPaymentInformation(req.getPaymentInformation());
forward.setBillerId(req.getBillerId());
forward.setBillerName(req.getBillerName());
forward.setBillerCategory(req.getBillerCategory());
forward.setMacAdress(req.getMacAdress());
forward.setCustomerMobNo(req.getCustomerMobNo());
forward.setTxnAmount(req.getTxnAmount());
forward.setPaymentRefId(req.getPaymentRefId());
forward.setClientReqId(req.getClientReqId());
forward.setPaymentChannel(req.getPaymentChannel());
forward.setDeviceBlockTags(req.getDeviceBlockTags());
forward.setCustomerParamsRequest(req.getCustomerParams());
forward.setRemitterIdentity(req.getRemitterIdentity());
forward.setAmountBreakSet(req.getAmountBreakSet());
return forward;
}
public FetchComplaintForwardRequest fetchComplaintForwardRequestMap(ComplaintRequestDTO complainRequestDTO) {
FetchComplaintForwardRequest forward = new FetchComplaintForwardRequest();
forward.setTicketDescription(complainRequestDTO.getTicketDescription());
forward.setTicketDisposition(complainRequestDTO.getTicketDisposition());
forward.setTicketDispositionCode(complainRequestDTO.getTicketDispositionCode());
forward.setTxnId(complainRequestDTO.getTxnId());
return forward;
}
public FetchTicketLatestStatusRequest fetchTicketLatestStatusRequestMap(GetTicketLatestStausRequest request) {
FetchTicketLatestStatusRequest forward = new FetchTicketLatestStatusRequest();
forward.setTicketId(request.getTicketId());
forward.setTxnNpciId(request.getTxnNpciId());
return forward;
}
public void savePaymentStartRecord(PaymentStartUserRequest request, PaymentStartApiResponse apiResponse,
String txnId, String orderNo, String requestJson, String rawResponse, String responseType) {
PaymentStartRecord record = new PaymentStartRecord();
record.setOrderNo(orderNo);
record.setRequestId(request.getReqId());
record.setClientMid(request.getMid());
record.setClientUserId(request.getClientUserId());
record.setInternalTxnId(txnId);
record.setAmount(Optional.ofNullable(apiResponse.getResponseData().getAmount()).orElse("0.00"));
record.setMid(Optional.ofNullable(apiResponse.getResponseData().getMid()).orElse("DUMMY_MID"));
record.setTxnId(Optional.ofNullable(apiResponse.getResponseData().getTxnId()).orElse("DUMMY_TXN"));
record.setQrString(Optional.ofNullable(apiResponse.getResponseData().getQrString()).orElse("NO_QR"));
record.setCreatedOn(Optional.ofNullable(apiResponse.getResponseData().getCreatedOn()).orElse(LocalDateTime.now().toString()));
record.setTxnStatus("PENDING");
// store the original request body and raw response
record.setRequestBody(requestJson);
record.setResponseBody(rawResponse);
record.setResponseType(responseType);
paymentStartRecordRepository.save(record);
}
public TransactionHistoryMasterDTO toDTO(TransactionMaster transactionMaster) {
if (transactionMaster == null) {
// Helper to parse incoming ISO date/time strings (with optional offset) into LocalDateTime
private LocalDateTime parseToLocalDateTime(String dateStr) {
if (dateStr == null || dateStr.isBlank()) {
return null;
}
try {
// Try parsing with offset first (e.g., 2023-04-19T17:28:05.508679Z or with +05:30)
OffsetDateTime odt = OffsetDateTime.parse(dateStr);
return odt.toLocalDateTime();
} catch (Exception e) {
try {
// Fallback to LocalDateTime without offset
return LocalDateTime.parse(dateStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
} catch (Exception ex) {
LOGGER.warn("Unable to parse date string to LocalDateTime: {}", dateStr);
return null;
}
}
}
// Create a new DTO and set the values from the entity
// Convert TransactionMaster to master DTO
public TransactionHistoryMasterDTO toDTO(TransactionMaster transactionMaster) {
if (transactionMaster == null) return null;
TransactionHistoryMasterDTO dto = new TransactionHistoryMasterDTO();
dto.setBankTxnId(transactionMaster.getBankTxnId());
dto.setTxnId(transactionMaster.getTxnId());
@@ -1174,16 +1041,12 @@ record.setTxnStatus("PENDING");
dto.setModifiedDate(transactionMaster.getModifiedDate());
dto.setCreatedEpochDate(transactionMaster.getCreatedEpochDate());
dto.setModifiedEpochDate(transactionMaster.getModifiedEpochDate());
return dto;
}
// Convert TransactionMaster to particular details DTO (used with method references)
public TransactionHistoryParticularDetailsDTO billerRemainingDetails(TransactionMaster transactionMaster) {
if (transactionMaster == null) {
return null;
}
// Create a new DTO and set the values from the entity
if (transactionMaster == null) return null;
TransactionHistoryParticularDetailsDTO dto = new TransactionHistoryParticularDetailsDTO();
dto.setBankTxnId(transactionMaster.getBankTxnId());
dto.setTxnId(transactionMaster.getTxnId());
@@ -1192,45 +1055,110 @@ record.setTxnStatus("PENDING");
dto.setBillerName(transactionMaster.getBillerName());
dto.setStatus(transactionMaster.getStatus());
dto.setTotalTxnAmount(transactionMaster.getTotalTxnAmount());
return dto;
}
// Map BillPaymentRequest to forward request used by external BBPS API
public BillPaymentForwardRequest billPaymentForwardRequest(BillPaymentRequest req) {
BillPaymentForwardRequest forward = new BillPaymentForwardRequest();
forward.setRefId(req.getRefId());
forward.setBillId(req.getBillId());
forward.setAmountOptions(req.isAmountOptions());
forward.setPaymentMode(req.getPaymentMode());
forward.setPaymentInformation(req.getPaymentInformation());
forward.setBillerId(req.getBillerId());
forward.setBillerName(req.getBillerName());
forward.setBillerCategory(req.getBillerCategory());
forward.setMacAdress(req.getMacAdress());
forward.setCustomerMobNo(req.getCustomerMobNo());
forward.setTxnAmount(req.getTxnAmount());
forward.setPaymentRefId(req.getPaymentRefId());
forward.setClientReqId(req.getClientReqId());
forward.setPaymentChannel(req.getPaymentChannel());
forward.setDeviceBlockTags(req.getDeviceBlockTags());
forward.setCustomerParamsRequest(req.getCustomerParams());
forward.setRemitterIdentity(req.getRemitterIdentity());
forward.setAmountBreakSet(req.getAmountBreakSet());
return forward;
}
// Map PaymentStartUserRequest + API response into PaymentStartRecord and persist
public void savePaymentStartRecord(PaymentStartUserRequest request, PaymentStartApiResponse apiResponse,
String txnId, String orderNo, String requestJson, String rawResponse, String responseType) {
PaymentStartRecord record = new PaymentStartRecord();
record.setOrderNo(orderNo);
record.setRequestId(request.getReqId());
record.setClientMid(request.getMid());
record.setClientUserId(request.getClientUserId());
record.setInternalTxnId(txnId);
if (apiResponse != null && apiResponse.getResponseData() != null) {
record.setAmount(Optional.ofNullable(apiResponse.getResponseData().getAmount()).orElse("0.00"));
record.setMid(Optional.ofNullable(apiResponse.getResponseData().getMid()).orElse("DUMMY_MID"));
record.setTxnId(Optional.ofNullable(apiResponse.getResponseData().getTxnId()).orElse("DUMMY_TXN"));
record.setQrString(Optional.ofNullable(apiResponse.getResponseData().getQrString()).orElse("NO_QR"));
// parse createdOn string into LocalDateTime and set on Auditable
LocalDateTime createdOn = parseToLocalDateTime(apiResponse.getResponseData().getCreatedOn());
if (createdOn == null) createdOn = LocalDateTime.now();
record.setCreatedOn(createdOn);
// default status pending
record.setTxnStatus("PENDING");
} else {
record.setAmount("0.00");
record.setMid(request.getMid());
record.setTxnStatus("PENDING");
record.setCreatedOn(LocalDateTime.now());
}
// store the original request body and raw response
record.setRequestBody(requestJson);
record.setResponseBody(rawResponse);
record.setResponseType(responseType);
paymentStartRecordRepository.save(record);
}
// Map ComplaintRequestDTO to forward request for complaint API
public FetchComplaintForwardRequest fetchComplaintForwardRequestMap(ComplaintRequestDTO complainRequestDTO) {
FetchComplaintForwardRequest forward = new FetchComplaintForwardRequest();
forward.setTicketDescription(complainRequestDTO.getTicketDescription());
forward.setTicketDisposition(complainRequestDTO.getTicketDisposition());
forward.setTicketDispositionCode(complainRequestDTO.getTicketDispositionCode());
forward.setTxnId(complainRequestDTO.getTxnId());
return forward;
}
// Map GetTicketLatestStausRequest to forward request
public FetchTicketLatestStatusRequest fetchTicketLatestStatusRequestMap(GetTicketLatestStausRequest request) {
FetchTicketLatestStatusRequest forward = new FetchTicketLatestStatusRequest();
forward.setTicketId(request.getTicketId());
forward.setTxnNpciId(request.getTxnNpciId());
return forward;
}
// Check if complaint can be raised (true if within 24 hours of transactionCreatedDateString)
public static boolean isComplaintAllowed(String transactionCreatedDateString) {
// Define the format of the transaction creation date including the time zone
// offset
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX");
if (transactionCreatedDateString == null || transactionCreatedDateString.isBlank()) return false;
try {
// Parse the transaction creation date string to OffsetDateTime (handles time
// zone)
OffsetDateTime transactionCreatedDate = OffsetDateTime.parse(transactionCreatedDateString, formatter);
// Get the current time (with offset)
OffsetDateTime transactionCreatedDate = OffsetDateTime.parse(transactionCreatedDateString);
OffsetDateTime currentTime = OffsetDateTime.now();
// Calculate the difference in hours
long hoursDifference = ChronoUnit.HOURS.between(transactionCreatedDate, currentTime);
// Return true if complaint can be raised (i.e., within 24 hours)
return hoursDifference >= 24;
// complaint allowed if within 24 hours
return hoursDifference <= 24;
} catch (Exception e) {
// Handle invalid date format or other parsing issues
System.err.println("Invalid date format: " + e.getMessage());
LOGGER.warn("isComplaintAllowed - invalid date string: {}", transactionCreatedDateString);
return false;
}
}
// Persist complaint response entity
public String saveComplaintResponseEntity(ComplaintResponse responseWrapper, String requestId, String txnId,
String userId) {
// 1. Convert ComplaintResponse DTO to ComplaintResponseEntity
if (responseWrapper == null || responseWrapper.getTicketDetails() == null) {
return "No data";
}
ComplaintResponseEntity complaintResponseEntity = new ComplaintResponseEntity();
// Map fields from DTO to entity
complaintResponseEntity.setRefId(responseWrapper.getTicketDetails().getRefId()); // For example, generate a
// unique ID
complaintResponseEntity.setRefId(responseWrapper.getTicketDetails().getRefId());
complaintResponseEntity.setTxnNpciId(responseWrapper.getTicketDetails().getTxnNpciId());
complaintResponseEntity.setTicketId(responseWrapper.getTicketDetails().getTicketId());
complaintResponseEntity.setTicketType(responseWrapper.getTicketDetails().getTicketType());
@@ -1238,36 +1166,107 @@ record.setTxnStatus("PENDING");
complaintResponseEntity.setTicketDesp(responseWrapper.getTicketDetails().getTicketDesp());
complaintResponseEntity.setTicketDesr(responseWrapper.getTicketDetails().getTicketDesr());
// Additional fields from ComplaintResponse DTO
complaintResponseEntity.setMessage(responseWrapper.getMessage());
complaintResponseEntity.setRemarks(responseWrapper.getRemarks());
complaintResponseEntity.setStatus(responseWrapper.getStatus());
complaintResponseEntity.setStatusCode(responseWrapper.getStatusCode());
// Set requestId and txnId from parameters
complaintResponseEntity.setReqId(requestId);
complaintResponseEntity.setTxnId(txnId);
complaintResponseEntity.setUserId(userId);
complaintResponseEntity.setCreateDateTime(new Date());
// If you need a separate complaintTicketId, you can set it here
complaintResponseEntity.setComplaintTicketId(generateComplaintTicketId()); // Generate or set manually
complaintResponseEntity.setComplaintTicketId(generateComplaintTicketId());
// Save the entity
complaintResponseRepository.save(complaintResponseEntity);
ComplaintResponseEntity savedEntity = complaintResponseRepository.save(complaintResponseEntity);
// Check if the entity is saved successfully and return count (1 for success)
if (savedEntity != null) {
return "1 record saved with RefId: " + savedEntity.toString();
} else {
return "Failed to save complaint response.";
ComplaintResponseEntity saved = complaintResponseRepository.save(complaintResponseEntity);
if (saved != null) {
return "1 record saved with id=" + saved.getId();
}
return "Failed to save";
}
// Save Complain Response From DB
private String generateComplaintTicketId() {
// Logic for generating complaint ticket ID
return "CMP-" + UUID.randomUUID().toString();
}
// Minimal mapping helpers used by AgentServiceImpl
public com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest fetchBillForwardRequestMap(
com.billpaymentservice.bbps.dto.request.FetchBillRequest req) {
if (req == null) return null;
com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest f = new com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest();
f.setBillerId(req.getBillerId());
f.setBillerName(req.getBillerName());
f.setBillerCategory(req.getBillerCategory());
f.setClientReqId(req.getClientReqId());
f.setMacAdress(req.getMacAdress());
f.setCustomerMobNo(req.getCustomerMobNo());
f.setRemitterName(req.getRemitterName());
f.setPaymentChannel(req.getPaymentChannel());
f.setDeviceBlockTags(req.getDeviceBlockTags());
f.setCustomerParamsRequest(req.getCustomerParamsRequest());
f.setRemitterIdentity(req.getRemitterIdentity());
return f;
}
public com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(
com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest req) {
if (req == null) return null;
com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest f = new com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest();
f.setBillerId(req.getBillerId());
f.setBillerName(req.getBillerName());
f.setBillerCategory(req.getBillerCategory());
f.setCustomerMobNo(req.getCustomerMobNo());
f.setClientReqId(req.getClientReqId());
f.setMacAddress(req.getMacAddress());
f.setCustomerParamsRequest(req.getCustomerParamsRequest());
return f;
}
public void saveBillValidation(com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse responseWrapper,
com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest billRequest, String txnId) {
if (responseWrapper == null || billRequest == null) return;
BillValidation entity = new BillValidation();
entity.setBillId(responseWrapper.getBillId());
entity.setRefId(responseWrapper.getRefId());
entity.setBillerId(responseWrapper.getBillerId());
entity.setStatus(responseWrapper.getStatus());
entity.setActionType(responseWrapper.getActionType());
entity.setUserId(responseWrapper.getUserId());
entity.setBillerResponse(responseWrapper.getBillerResponse());
entity.setTxnId(txnId);
entity.setReqId(billRequest.getReqId());
// Map additionalInfo if present (minimal mapping)
if (responseWrapper.getAdditionalInfo() != null) {
List<AdditionalInfoBillValidate> addList = new ArrayList<>();
for (com.billpaymentservice.bbps.dto.AdditionalInfoBillValidateDTO ai : responseWrapper.getAdditionalInfo()) {
AdditionalInfoBillValidate info = new AdditionalInfoBillValidate();
// DTO only has name & value
info.setName(ai.getName());
info.setValue(ai.getValue());
info.setBill(entity);
addList.add(info);
}
entity.setAdditionalInfo(addList);
}
// Map customerParams if present (minimal mapping)
if (responseWrapper.getCustomerParams() != null) {
List<CustomerParamBillValidation> cpList = new ArrayList<>();
for (com.billpaymentservice.bbps.dto.CustomerParamDAO cp : responseWrapper.getCustomerParams()) {
CustomerParamBillValidation param = new CustomerParamBillValidation();
param.setName(cp.getName());
param.setValue(cp.getValue());
param.setType(cp.getType());
param.setBill(entity);
cpList.add(param);
}
entity.setCustomerParams(cpList);
}
// Persist
try {
billValidationRepository.save(entity);
} catch (Exception e) {
LOGGER.error("Error saving BillValidation: {}", e.getMessage(), e);
}
}
}
@@ -183,7 +183,8 @@ public class Helper {
user.setName(request.getName());
user.setEmail(request.getEmail());
user.setMid(request.getMid());
user.setCreateDateTime(new Date());
// set audit createdOn timestamp
user.setCreatedOn(LocalDateTime.now());
// Generate a unique userId (UUID)
String uniqueUserId = generateUniqueUserId();
user.setUserId(uniqueUserId);
@@ -18,7 +18,7 @@ swagger.server.description=Local Development Server
# DataSource
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
spring.datasource.url=jdbc:postgresql://localhost:5432/bbps_enhanced
spring.datasource.username=postgres
#spring.datasource.password=UAT@DB_2025
+1 -1
View File
@@ -21,7 +21,7 @@ spring.profiles.active=local
# DataSource
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS_Enhanced
spring.datasource.username=postgres
#spring.datasource.password=UAT@DB_2025