solved conflicts
This commit is contained in:
@@ -172,7 +172,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
<finalName>BBPS</finalName>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.billpaymentservice.bbps.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class CORSConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*") // Or specific origin like "http://localhost:4200"
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
.allowedHeaders("*")
|
||||
.allowCredentials(false); // Set to true if you're sending cookies
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.billpaymentservice.bbps.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
|
||||
@Configuration
|
||||
public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowedOrigins(Arrays.asList("*")); // Or use specific origin like "http://localhost:4200"
|
||||
config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
|
||||
config.setAllowedHeaders(Arrays.asList("*"));
|
||||
config.setAllowCredentials(false); // true only if you're sending cookies
|
||||
|
||||
// Use UrlBasedCorsConfigurationSource as it implements CorsConfigurationSource
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", config); // Apply CORS to all paths
|
||||
return source; // Return as CorsConfigurationSource
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.billpaymentservice.bbps.controller;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -16,45 +17,37 @@ import com.billpaymentservice.bbps.service.AgentService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/agent")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class AgentController {
|
||||
|
||||
private final AgentService agentService;
|
||||
private final AgentService agentService;
|
||||
|
||||
public AgentController(AgentService agentService) {
|
||||
this.agentService = agentService;
|
||||
}
|
||||
public AgentController(AgentService agentService) {
|
||||
this.agentService = agentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches bill details from external BBPS service
|
||||
*/
|
||||
@PostMapping(
|
||||
value = "/requestBillFetch",
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE
|
||||
)
|
||||
public ResponseEntity<ResponseModel> requestBillFetch(
|
||||
@Validated @RequestBody FetchBillRequest fetchBillRequest) {
|
||||
/**
|
||||
* Fetches bill details from external BBPS service
|
||||
*/
|
||||
@PostMapping(value = "/requestBillFetch", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> requestBillFetch(@Validated @RequestBody FetchBillRequest fetchBillRequest) {
|
||||
|
||||
ResponseModel response = agentService.initiateBillFetch(fetchBillRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches bill details from external BBPS service
|
||||
*/
|
||||
@PostMapping(
|
||||
value = "/fetchBillById",
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE
|
||||
)
|
||||
public ResponseEntity<ResponseModel> fetchBillById(
|
||||
@Validated @RequestBody BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||
ResponseModel response = agentService.initiateBillFetch(fetchBillRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
ResponseModel response = agentService.fetchBillById(billFetchByBillIdRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Fetches bill details from external BBPS service
|
||||
*/
|
||||
@PostMapping(value = "/fetchBillById", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> fetchBillById(
|
||||
@Validated @RequestBody BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||
|
||||
ResponseModel response = agentService.fetchBillById(billFetchByBillIdRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches bill details validate from external BBPS service
|
||||
*/
|
||||
@PostMapping(value = "/requestBillValidate", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@@ -69,7 +62,8 @@ public class AgentController {
|
||||
* Fetches bill details by bill Id from external BBPS service
|
||||
*/
|
||||
@PostMapping(value = "/requestBillValidateByBillId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> requestBillByBillId(@Validated @RequestBody BillFetchByBillIdRequest billRequest) {
|
||||
public ResponseEntity<ResponseModel> requestBillByBillId(
|
||||
@Validated @RequestBody BillFetchByBillIdRequest billRequest) {
|
||||
|
||||
ResponseModel response = agentService.initiateBillValidateByBillId(billRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -25,6 +26,7 @@ import jakarta.validation.Valid;
|
||||
@RequestMapping("/masterData")
|
||||
@RestController
|
||||
@Validated
|
||||
@CrossOrigin(origins="*")
|
||||
public class MasterDataController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MasterDataController.class);
|
||||
@@ -73,7 +75,7 @@ public class MasterDataController {
|
||||
return ResponseEntity.ok(masterDataService.getCustomerParamByBillerId(customerParamRequest));
|
||||
}
|
||||
/**
|
||||
* Get All Master Data .The parameter is different from the data we are getting
|
||||
* Get All Master Data .The parameter is different from the data we are getting Made By Arham
|
||||
* in the MasterRequest
|
||||
**/
|
||||
@PostMapping("/getAllMastersData")
|
||||
@@ -81,14 +83,14 @@ public class MasterDataController {
|
||||
return masterDataService.getMasterData(masterRequest);
|
||||
}
|
||||
|
||||
/** POST Master Category Wise API Fetch Category Wise from BBPS URL **/
|
||||
/** POST Master CategoryResponseList Wise API Fetch CategoryResponseList Wise from BBPS URL Made By Arham **/
|
||||
@PostMapping(value = "/getMasterCategoryWise", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> getMasterDataCategoryWise(
|
||||
@Validated @RequestBody MasterCategoryRequest masterRequest) {
|
||||
@Valid @RequestBody MasterCategoryRequest masterRequest) {
|
||||
return ResponseEntity.ok(masterDataService.fetchMasterDataCategoryWise(masterRequest));
|
||||
}
|
||||
|
||||
/** POST Customer Param Groups API Fetch Category Wise from BBPS URL **/
|
||||
/** POST Customer Param Groups API Fetch CategoryResponseList Wise from BBPS URL Made By Arham**/
|
||||
@PostMapping(value = "/customerParamGroupsByBillerId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> getCustomerParamGroup(
|
||||
@Validated @RequestBody BillerDetailRequest requestModel) {
|
||||
@@ -96,8 +98,8 @@ public class MasterDataController {
|
||||
}
|
||||
|
||||
/**
|
||||
* POST Fetch All AMount Options By Biller Id API Fetch Category Wise from BBPS
|
||||
* URL
|
||||
* POST Fetch All AMount Options By Biller Id API Fetch CategoryResponseList Wise from BBPS
|
||||
* URL Made By Arham
|
||||
**/
|
||||
@PostMapping(value = "/fetchAmountOptionsByBillerId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> fetchAllMasterAmountOptionsByBillerId(
|
||||
@@ -106,8 +108,8 @@ public class MasterDataController {
|
||||
}
|
||||
|
||||
/**
|
||||
* POST Fetch All AMount Options By Biller Id API Fetch Category Wise from BBPS
|
||||
* URL
|
||||
* POST Fetch All AMount Options By Biller Id API Fetch CategoryResponseList Wise from BBPS
|
||||
* URL Made By Arham
|
||||
**/
|
||||
@PostMapping(value = "/fetchAllPlanCategoriesByBillerId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> fetchPlanCategories(@Validated @RequestBody BillerDetailRequest requestModel) {
|
||||
@@ -115,7 +117,7 @@ public class MasterDataController {
|
||||
}
|
||||
|
||||
/**
|
||||
* POST Fetch Initiating Channel API Fetch Category Wise from BBPS URL
|
||||
* POST Fetch Initiating Channel API Fetch CategoryResponseList Wise from BBPS URL Made By Arham
|
||||
**/
|
||||
@PostMapping(value = "/initiatingChannel", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> initiatingChannel(@Validated @RequestBody BillerDetailRequest requestModel) {
|
||||
@@ -123,7 +125,7 @@ public class MasterDataController {
|
||||
}
|
||||
|
||||
/**
|
||||
* POST Fetch All AMount Options By Biller Id API Fetch Category Wise from BBPS
|
||||
* POST Fetch All AMount Options By Biller Id API Fetch CategoryResponseList Wise from BBPS Made By Arham
|
||||
* URL
|
||||
**/
|
||||
@PostMapping(value = "/fetchPlanByCategoryName", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@@ -10,43 +10,42 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public abstract class BaseClass {
|
||||
|
||||
@NotBlank(message = "MID cannot be null or blank")
|
||||
private String mid;
|
||||
|
||||
private String mid;
|
||||
|
||||
@NotBlank(message = "Secret key cannot be null or blank")
|
||||
private String secretKey;
|
||||
|
||||
@NotBlank(message = "Request ID cannot be null or blank")
|
||||
private String reqId;
|
||||
|
||||
private DeviceDetail deviceDetial;
|
||||
|
||||
|
||||
private String udf1;
|
||||
private DeviceDetail deviceDetial;
|
||||
// ✅ 10 User Defined Fields (UDF1–UDF10)
|
||||
private String udf1;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf2;
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf2;
|
||||
|
||||
private String udf3;
|
||||
private String udf3;
|
||||
|
||||
private String udf4;
|
||||
private String udf4;
|
||||
|
||||
private String udf5;
|
||||
private String udf5;
|
||||
|
||||
private String udf6;
|
||||
|
||||
private String udf7;
|
||||
private String udf6;
|
||||
|
||||
private String udf8;
|
||||
private String udf7;
|
||||
|
||||
private String udf9;
|
||||
private String udf8;
|
||||
|
||||
private String udf10;
|
||||
private String udf9;
|
||||
|
||||
private String udf10;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public class FetchBillValidatestRequest extends BaseClass {
|
||||
@NotNull
|
||||
private String billerName; // String, Name of the biller
|
||||
@NotNull
|
||||
private String billerCategory; // String, Category of the biller
|
||||
private String billerCategory; // String, CategoryResponseList of the biller
|
||||
@NotNull
|
||||
private String customerMobNo; // String, Mobile of the Customer
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.billpaymentservice.bbps.dto.request;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@@ -19,6 +20,8 @@ public class MasterCategoryRequest extends BaseClass {
|
||||
|
||||
private Integer pageStart = 0;
|
||||
|
||||
private Integer pageEnd = 10;
|
||||
@NotNull(message = "pageEnd is required")
|
||||
@Min(value = 1, message = "pageEnd must be greater than 0")
|
||||
private Integer pageEnd;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "additional_info")
|
||||
@Getter
|
||||
@Setter
|
||||
public class AdditionalInfoPlans {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "plan_ddditional_info_id")
|
||||
private Long planAdditionalInfoId;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
private List<PlanTag> tags;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "amount_option_biller_id")
|
||||
public class AmountOptionByBillerId extends Auditable<String> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id; // Use Long for auto-increment identity
|
||||
|
||||
@Column(name = "amount_options")
|
||||
private Boolean amountOptions; // This is true or false
|
||||
|
||||
@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
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "amount_option_details")
|
||||
public class AmountOptionDetails {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id; // Primary Key
|
||||
|
||||
@Column(name = "amount_breakup_set")
|
||||
private String amountBreakupSet; // Each string in the list (BASE_BILL_AMOUNT, Apple_Sab, etc.)
|
||||
|
||||
@Column(name = "amount_option_id")
|
||||
private String amountOptionId; // Now a String (change this from Long to String, to match the foreign key)
|
||||
|
||||
@Column(name = "amount_option_id_long")
|
||||
private Long amountOptionIdLong; // Long type for foreign key (added for the FK relationship)
|
||||
|
||||
@Column(name = "request_id")
|
||||
private String requestId;
|
||||
|
||||
@Column(name = "txn_id")
|
||||
private String txnId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import com.billpaymentservice.bbps.audit.Auditable;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "biller_category_icon")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BillerCategoryIcon extends Auditable<String>{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "icon_id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "icon_data")
|
||||
private String iconData;
|
||||
|
||||
@Column(name = "icon_type")
|
||||
private String iconType;
|
||||
|
||||
// Owning side of One-to-One
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "biller_id", nullable = false, referencedColumnName = "biller_id",
|
||||
foreignKey = @ForeignKey(name = "fk_icon_biller"))
|
||||
private BillerCategoryWise biller;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import com.billpaymentservice.bbps.audit.Auditable;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "biller_category_wise")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BillerCategoryWise extends Auditable<String> {
|
||||
|
||||
@Id
|
||||
@Column(name = "biller_id")
|
||||
private String billerId;
|
||||
|
||||
@Column(name = "biller_name", columnDefinition = "TEXT")
|
||||
private String billerName;
|
||||
|
||||
@Column(name = "biller_type", columnDefinition = "TEXT")
|
||||
private String billerType;
|
||||
|
||||
@Column(name = "biller_category", columnDefinition = "TEXT")
|
||||
private String billerCategory;
|
||||
|
||||
@Column(name = "biller_coverage", columnDefinition = "TEXT")
|
||||
private String billerCoverage;
|
||||
|
||||
@Column(name = "biller_response_type", columnDefinition = "TEXT")
|
||||
private String billerResponseType;
|
||||
|
||||
@Column(name = "biller_description", columnDefinition = "TEXT")
|
||||
private String billerDescription;
|
||||
|
||||
@Column(name = "plan_mdm_requirement", columnDefinition = "TEXT")
|
||||
private String planMDMRequirement;
|
||||
|
||||
@Column(name = "adhoc_biller", columnDefinition = "TEXT")
|
||||
private String adhocBiller;
|
||||
|
||||
@Column(name = "payment_amount_exactness", columnDefinition = "TEXT")
|
||||
private String paymentAmountExactness;
|
||||
|
||||
@Column(name = "request_id")
|
||||
private String requestId;
|
||||
|
||||
@Column(name = "txn_id")
|
||||
private String txnId;
|
||||
|
||||
// One-to-One mapping with icon
|
||||
@OneToOne(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private BillerCategoryIcon icon;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import com.billpaymentservice.bbps.audit.Auditable;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "category_response_list")
|
||||
@Getter
|
||||
@Setter
|
||||
public class CategoryResponseList extends Auditable<String> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "category_resp_list", columnDefinition = "TEXT")
|
||||
private String categoryRespList;
|
||||
|
||||
@Column(name = "reqquest_id")
|
||||
private String requestId;
|
||||
|
||||
@Column(name = "txn_id")
|
||||
private String txnId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
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;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "customer_param_group_by_biller_id")
|
||||
public class CustomerParamGroupById extends Auditable<String> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "group_id")
|
||||
private String groupId; // Unique ID for each group, it’s a UUID
|
||||
|
||||
@Column(name = "name")
|
||||
private String name; // Name of the group
|
||||
|
||||
@Column(name = "input")
|
||||
private String input; // Input data for the group (can be a simple string)
|
||||
|
||||
// One-to-many relationship with parameters of this group
|
||||
@OneToMany(mappedBy = "group", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<GroupParam> params; // List of parameters related to this group
|
||||
|
||||
// One-to-many relationship with child groups (recursively)
|
||||
@OneToMany(mappedBy = "parentGroup", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<CustomerParamGroupById> childGroups; // Child groups of this group
|
||||
|
||||
// Many-to-one relationship with parent group (optional, for root groups, this
|
||||
// will be null)
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "parent_group_id")
|
||||
private CustomerParamGroupById parentGroup; // Link to the parent group
|
||||
|
||||
@Column(name = "request_id")
|
||||
private String requestId;
|
||||
|
||||
@Column(name = "txn_id")
|
||||
private String txnId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import com.billpaymentservice.bbps.audit.Auditable;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "fetch_bill_validate_response")
|
||||
public class FetchBillValidate extends Auditable<String> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "bill_id")
|
||||
private String billId;
|
||||
|
||||
@Column(name = "ref_id")
|
||||
private String refId;
|
||||
|
||||
@Column(name = "biller_id")
|
||||
private String billerId;
|
||||
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
@Column(name = "action_type")
|
||||
private String actionType;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
|
||||
@Column(name = "biller_response")
|
||||
private String billerResponse;
|
||||
|
||||
@Column(name = "additional_info")
|
||||
private String additionalInfo;
|
||||
|
||||
@Column(name = "customer_params")
|
||||
private String customerParams;
|
||||
|
||||
@Column(name = "plan_info_daos")
|
||||
private String planInfoDaos;
|
||||
|
||||
@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 = "request_id")
|
||||
private String requestId;
|
||||
|
||||
@Column(name = "txn_id")
|
||||
private String txnId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "group_params")
|
||||
public class GroupParam {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "param_name")
|
||||
private String paramName; // The parameter name (e.g., "Admission No")
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "group_id")
|
||||
private CustomerParamGroupById group; // Link to the group this parameter belongs to
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "plan")
|
||||
@Getter
|
||||
@Setter
|
||||
public class Plan {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "plan_id")
|
||||
private String planId;
|
||||
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
@Column(name = "biller_id")
|
||||
private String billerId;
|
||||
|
||||
@Column(name = "category_type")
|
||||
private String categoryType;
|
||||
|
||||
@Column(name = "amount_rupees")
|
||||
private String amountInRupees;
|
||||
|
||||
@Column(name = "effectv_form")
|
||||
private String effctvFrom;
|
||||
|
||||
@Column(name = "effectv_to")
|
||||
private String effctvTo;
|
||||
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "plan")
|
||||
private List<PlanCategorySubType> categorySubTypes; // List of categorySubTypes
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "plans_list_id")
|
||||
private PlansList plansList;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "additional_info_id")
|
||||
private AdditionalInfoPlans additionalInfo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "plan_category_sub_type")
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlanCategorySubType {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String categorySubType;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "plan_id")
|
||||
private Plan plan;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import com.billpaymentservice.bbps.audit.Auditable;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "plan_response")
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlanResponses extends Auditable<String> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "plans_list_id")
|
||||
private PlansList plansList;
|
||||
|
||||
@Column(name = "page_no")
|
||||
private int pageNo;
|
||||
|
||||
@Column(name = "page_size")
|
||||
private int pageSize;
|
||||
|
||||
@Column(name = "total_elements")
|
||||
private long totalElements;
|
||||
|
||||
@Column(name = "total_pages")
|
||||
private int totalPages;
|
||||
|
||||
@Column(name = "request_id")
|
||||
private String requestId;
|
||||
|
||||
@Column(name = "txn_id")
|
||||
private String txnId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "plan_tag")
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlanTag {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private UUID tagId;
|
||||
|
||||
@Column(name="name")
|
||||
private String name;
|
||||
|
||||
@Column(name="value")
|
||||
private String value;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "plan_id")
|
||||
private Plan plan;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "plans_list")
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlansList {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "plansList")
|
||||
private List<Plan> plans;
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.AmountOptionByBillerId;
|
||||
|
||||
@Repository
|
||||
public interface AmountOptionByBillerIdRepository extends JpaRepository<AmountOptionByBillerId, Long> {
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.BillerCategoryIcon;
|
||||
|
||||
@Repository
|
||||
public interface BillerCategoryIconRepository extends JpaRepository<BillerCategoryIcon, Long> {
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.BillerCategoryWise;
|
||||
|
||||
@Repository
|
||||
public interface BillerCategoryWiseRepository extends JpaRepository<BillerCategoryWise, String>{
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.CategoryResponseList;
|
||||
|
||||
@Repository
|
||||
public interface CategoryResponseListRepository extends JpaRepository<CategoryResponseList, Long> {
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamGroupById;
|
||||
|
||||
@Repository
|
||||
public interface CustomerParamGroupByBillerIdRepository extends JpaRepository<CustomerParamGroupById, Long> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.FetchBillValidate;
|
||||
|
||||
@Repository
|
||||
public interface FetchBillValidateRepository extends JpaRepository<FetchBillValidate, Long> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.PlanResponses;
|
||||
|
||||
|
||||
@Repository
|
||||
public interface PlanResponseRepository extends JpaRepository<PlanResponses, Long> {
|
||||
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
|
||||
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
|
||||
import com.billpaymentservice.bbps.service.AgentService;
|
||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
||||
import com.billpaymentservice.bbps.util.Helper;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@@ -49,234 +50,230 @@ public class AgentServiceImpl implements AgentService {
|
||||
private final HttpService httpService;
|
||||
private final Helper helper;
|
||||
private final BharatConnectMasterRepository beneficiaryDetailsRepository;
|
||||
private final BillerMapperHelper mapperHelper;
|
||||
private final BillMasterRepository billMasterRepository;
|
||||
private final BillInitateRepository billIntiateRepository;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AgentServiceImpl.class);
|
||||
|
||||
public AgentServiceImpl(RestClient restClient, HttpService httpService, Helper helper,
|
||||
BharatConnectMasterRepository beneficiaryDetailsRepository,InboundTraceLogRepository inboundTraceLogRepository,
|
||||
OutboundTraceLogRepository outboundTraceLogRepository, BillMasterRepository billMasterRepository,BillInitateRepository billIntiateRepository) {
|
||||
BharatConnectMasterRepository beneficiaryDetailsRepository,
|
||||
InboundTraceLogRepository inboundTraceLogRepository, OutboundTraceLogRepository outboundTraceLogRepository,
|
||||
BillMasterRepository billMasterRepository, BillInitateRepository billIntiateRepository,
|
||||
BillerMapperHelper mapperHelper) {
|
||||
this.restClient = restClient;
|
||||
this.httpService = httpService;
|
||||
this.helper = helper;
|
||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||
this.billMasterRepository = billMasterRepository;
|
||||
this. billIntiateRepository= billIntiateRepository;
|
||||
this.billIntiateRepository = billIntiateRepository;
|
||||
this.mapperHelper = mapperHelper;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest) {
|
||||
LOGGER.info("Initiating bill fetch for request ID: {} and MID", fetchBillRequest.getReqId(), fetchBillRequest.getMid());
|
||||
String apiName = "InitiateBillFetch";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = fetchBillRequest.getReqId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||
LOGGER.info("Initiating bill fetch for request ID: {} and MID", fetchBillRequest.getReqId(),
|
||||
fetchBillRequest.getMid());
|
||||
String apiName = "InitiateBillFetch";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = fetchBillRequest.getReqId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||
|
||||
helper.validateMerchant(fetchBillRequest.getMid());
|
||||
helper.validateMerchant(fetchBillRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
String requestJson = helper.convertObjectToJson(fetchBillRequest);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
String requestJson = helper.convertObjectToJson(fetchBillRequest);
|
||||
|
||||
// ✅ Create inbound & outbound logs
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, fetchBillRequest.getMid(), "POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST", requestJson);
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
|
||||
// ✅ Create inbound & outbound logs
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, fetchBillRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST",
|
||||
requestJson);
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, requestJson, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, requestJson, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Response received from BBPS: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Response received from BBPS: {}", responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid response received for txnId: {}", txnId);
|
||||
throw new CustomException(
|
||||
String.valueOf(dataMap.get("message")),
|
||||
String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks"))
|
||||
);
|
||||
}
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid response received for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
|
||||
BillMaster billMaster = new BillMaster();
|
||||
billMaster.setBillId((String) dataMap.get("billId"));
|
||||
billMaster.setReqId(fetchBillRequest.getReqId());
|
||||
billMaster.setTxnId(txnId);
|
||||
billMasterRepository.save(billMaster);
|
||||
LOGGER.info("BillMaster saved for billId: {}", billMaster.getBillId());
|
||||
BillMaster billMaster = new BillMaster();
|
||||
billMaster.setBillId((String) dataMap.get("billId"));
|
||||
billMaster.setReqId(fetchBillRequest.getReqId());
|
||||
billMaster.setTxnId(txnId);
|
||||
billMasterRepository.save(billMaster);
|
||||
LOGGER.info("BillMaster saved for billId: {}", billMaster.getBillId());
|
||||
|
||||
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
||||
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
||||
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
|
||||
BillInitiate billInitiate = new BillInitiate();
|
||||
billInitiate.setBillId((String) dataMap.get("billId"));
|
||||
billInitiate.setReqId(fetchBillRequest.getReqId());
|
||||
billInitiate.setTxnId(txnId);
|
||||
billIntiateRepository.save(billInitiate);
|
||||
LOGGER.info("BillInitiate entry saved for billId: {}", billInitiate.getBillId());
|
||||
BillInitiate billInitiate = new BillInitiate();
|
||||
billInitiate.setBillId((String) dataMap.get("billId"));
|
||||
billInitiate.setReqId(fetchBillRequest.getReqId());
|
||||
billInitiate.setTxnId(txnId);
|
||||
billIntiateRepository.save(billInitiate);
|
||||
LOGGER.info("BillInitiate entry saved for billId: {}", billInitiate.getBillId());
|
||||
|
||||
BillFetchByBillIdRequest billFetchByBillIdRequest = new BillFetchByBillIdRequest();
|
||||
billFetchByBillIdRequest.setBillId(fetchBillResponse.getBillId());
|
||||
billFetchByBillIdRequest.setMid(fetchBillRequest.getMid());
|
||||
billFetchByBillIdRequest.setReqId(requestId);
|
||||
LOGGER.info("Waiting for 2 seconds before fetching bill by ID...");
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId());
|
||||
return fetchBillById(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
BillFetchByBillIdRequest billFetchByBillIdRequest = new BillFetchByBillIdRequest();
|
||||
billFetchByBillIdRequest.setBillId(fetchBillResponse.getBillId());
|
||||
billFetchByBillIdRequest.setMid(fetchBillRequest.getMid());
|
||||
billFetchByBillIdRequest.setReqId(requestId);
|
||||
LOGGER.info("Waiting for 2 seconds before fetching bill by ID...");
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId());
|
||||
return fetchBillById(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest, InboundTraceLog inboundLog) {
|
||||
LOGGER.info("Fetching bill by BILLID for request ID={} and MID={}", billFetchByBillIdRequest.getReqId(), billFetchByBillIdRequest.getMid());
|
||||
String apiName = "FetchBillById";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + "1ced7566-1add-4e01-9ed6-04cd67ac9684";
|
||||
LOGGER.info("Fetching bill by BILLID for request ID={} and MID={}", billFetchByBillIdRequest.getReqId(),
|
||||
billFetchByBillIdRequest.getMid());
|
||||
String apiName = "FetchBillById";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + "1ced7566-1add-4e01-9ed6-04cd67ac9684";
|
||||
|
||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Bill FetchById Response: {}", responseData);
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Bill FetchById Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(
|
||||
String.valueOf(dataMap.get("message")),
|
||||
String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks"))
|
||||
);
|
||||
}
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
|
||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current Bill Status: {}", status);
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current Bill Status: {}", status);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
helper.saveOrUpdateBillerData(responseWrapper,billFetchByBillIdRequest);
|
||||
LOGGER.info("Bill data saved successfully for billId: {}", billId);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
helper.saveOrUpdateBillerData(responseWrapper, billFetchByBillIdRequest);
|
||||
LOGGER.info("Bill data saved successfully for billId: {}", billId);
|
||||
|
||||
return new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing BillById JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing BillById JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||
String apiName = "FetchBillById";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + "1ced7566-1add-4e01-9ed6-04cd67ac9684";
|
||||
String apiName = "FetchBillById";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + "1ced7566-1add-4e01-9ed6-04cd67ac9684";
|
||||
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
|
||||
try {
|
||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
LOGGER.debug("Merchant validated successfully for MID={}", billFetchByBillIdRequest.getMid());
|
||||
try {
|
||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
LOGGER.debug("Merchant validated successfully for MID={}", billFetchByBillIdRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
LOGGER.info("Calling external BBPS API for FetchBillById, URL={}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Response received from BBPS for billId={} : {}", billId, responseData);
|
||||
LOGGER.info("Calling external BBPS API for FetchBillById, URL={}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Response received from BBPS for billId={} : {}", billId, responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {});
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
LOGGER.warn("Invalid response structure received for billId={} | Response={}", billId, responseData);
|
||||
throw new CustomException(
|
||||
String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
||||
String.valueOf(dataMap.get("remarks"))
|
||||
);
|
||||
}
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
LOGGER.warn("Invalid response structure received for billId={} | Response={}", billId, responseData);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
|
||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
ResponseModel responseModel = new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.saveOrUpdateBillerData(responseWrapper, billFetchByBillIdRequest);
|
||||
LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus());
|
||||
helper.saveOrUpdateBillerData(responseWrapper, billFetchByBillIdRequest);
|
||||
LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus());
|
||||
|
||||
return responseModel;
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON for billId={} : {}", billId, e.getMessage(), e);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON for billId={} : {}", billId, e.getMessage(), e);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
|
||||
|
||||
LOGGER.info("Initiating bill Validate for request ID: {} and MID", fetchBillValidateRequest.getReqId(),
|
||||
fetchBillValidateRequest.getMid());
|
||||
@@ -313,6 +310,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Response received from BBPS: {}", responseData);
|
||||
|
||||
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
@@ -429,8 +428,11 @@ public class AgentServiceImpl implements AgentService {
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @Override public ResponseModel
|
||||
* initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
@@ -551,10 +553,9 @@ public class AgentServiceImpl implements AgentService {
|
||||
*
|
||||
* return responseModel; }
|
||||
*/
|
||||
|
||||
|
||||
/* POLLING METHOD
|
||||
* public ResponseModel fetchBillById(BillFetchByBillIdRequest
|
||||
|
||||
/*
|
||||
* POLLING METHOD public ResponseModel fetchBillById(BillFetchByBillIdRequest
|
||||
* billFetchByBillIdRequest, InboundTraceLog inboundLog) { String apiName =
|
||||
* "FetchBillById"; String txnId = helper.generateTxnId(15); String reqId =
|
||||
* billFetchByBillIdRequest.getReqId(); String billId =
|
||||
@@ -619,7 +620,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
* }
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
+118
-100
@@ -12,7 +12,10 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.CustomParamDTO;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.billpaymentservice.bbps.dto.MasterApiResponse;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
@@ -33,6 +36,7 @@ import com.billpaymentservice.bbps.dto.response.DispositionResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.PlanResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.PlaneCategoriesResponse;
|
||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||
import com.billpaymentservice.bbps.entites.BillerCategoryWise;
|
||||
import com.billpaymentservice.bbps.entites.BillerDetails;
|
||||
import com.billpaymentservice.bbps.entites.CustomParam;
|
||||
import com.billpaymentservice.bbps.entites.DispositionDetails;
|
||||
@@ -48,6 +52,7 @@ import com.billpaymentservice.bbps.repository.MerchantRepository;
|
||||
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
|
||||
import com.billpaymentservice.bbps.service.MasterDataService;
|
||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
||||
import com.billpaymentservice.bbps.util.EntityRelationshipUtil;
|
||||
import com.billpaymentservice.bbps.util.Helper;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@@ -62,7 +67,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Value("${master.data.url}")
|
||||
private String masterRegisterUrl;
|
||||
private final BharatConnectMasterRepository beneficiaryDetailsRepository;
|
||||
|
||||
private final BillerMapperHelper mapperHelper;
|
||||
private MerchantRepository merchantRegisterRepo;
|
||||
private HttpClientApi httpClientApi;
|
||||
private final DispositionRepository dispositionRepository;
|
||||
@@ -77,9 +82,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
public MasterDataServiceImpl(MerchantRepository merchantRegisterRepo, HttpService httpService,
|
||||
HttpClientApi httpClientApi, Helper helper, BillerDataRepository billerDataRespository,
|
||||
DispositionRepository dispositionRepository, BharatConnectMasterRepository beneficiaryDetailsRepository,
|
||||
InboundTraceLogRepository inboundTraceLogRepository,
|
||||
OutboundTraceLogRepository outboundTraceLogRepository,
|
||||
CustomParamRepository customParamReposiotory) {
|
||||
InboundTraceLogRepository inboundTraceLogRepository, OutboundTraceLogRepository outboundTraceLogRepository,
|
||||
BillerMapperHelper mapperHelper, CustomParamRepository customParamReposiotory) {
|
||||
this.merchantRegisterRepo = merchantRegisterRepo;
|
||||
this.httpService = httpService;
|
||||
this.httpClientApi = httpClientApi;
|
||||
@@ -89,7 +93,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
||||
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
||||
this.customParamReposiotory=customParamReposiotory;
|
||||
this.mapperHelper = mapperHelper;
|
||||
this.customParamReposiotory = customParamReposiotory;
|
||||
|
||||
}
|
||||
|
||||
@@ -117,8 +122,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
//LOGGER.info("Response Data: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
LOGGER.info("Response Data: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
@@ -145,12 +151,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
||||
LOGGER.info("Fetching Biller Detail By Biller Id for ReqId={} and MID={}", billerDetailRequest.getReqId(), billerDetailRequest.getMid());
|
||||
LOGGER.info("Fetching Biller Detail By Biller Id for ReqId={} and MID={}", billerDetailRequest.getReqId(),
|
||||
billerDetailRequest.getMid());
|
||||
|
||||
helper.validateMerchant(billerDetailRequest.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
@@ -159,8 +167,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String billerId = billerDetailRequest.getBillerId();
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
|
||||
String requestJson = helper.convertObjectToJson(billerDetailRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(), "POST",
|
||||
requestJson);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
@@ -193,20 +201,21 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
|
||||
|
||||
LOGGER.info("Fetching Customer Param By Biller Id for ReqId={} and MID={}", customerParamRequest.getReqId(), customerParamRequest.getMid());
|
||||
|
||||
LOGGER.info("Fetching Customer Param By Biller Id for ReqId={} and MID={}", customerParamRequest.getReqId(),
|
||||
customerParamRequest.getMid());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "GetCustomerParamByBillerId";
|
||||
String requestId = customerParamRequest.getReqId();
|
||||
String requestJson = helper.convertObjectToJson(customerParamRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(), "POST",
|
||||
requestJson);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
|
||||
try {
|
||||
helper.validateMerchant(customerParamRequest.getMid());
|
||||
@@ -231,21 +240,20 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
|
||||
|
||||
CustomParamResp responseWrapper = objectMapper.convertValue(dataMap, CustomParamResp.class);
|
||||
List<CustomParamDTO> customParams = responseWrapper.getCustomParamResp();
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
List<CustomParamDTO> customParam = responseWrapper.getCustomParamResp();
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
List<CustomParamDTO> customParam = responseWrapper.getCustomParamResp();
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
|
||||
// Map DTOs to entities
|
||||
List<CustomParam> entities = customParams.stream().map(dto -> mapper.map(dto, CustomParam.class))
|
||||
.collect(Collectors.toList());
|
||||
// Save all to DB
|
||||
customParamReposiotory.saveAll(entities);
|
||||
|
||||
// Map DTOs to entities
|
||||
List<CustomParam> entities = customParams.stream()
|
||||
.map(dto -> mapper.map(dto, CustomParam.class))
|
||||
.collect(Collectors.toList());
|
||||
// Save all to DB
|
||||
customParamReposiotory.saveAll(entities);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
@@ -261,12 +269,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
|
||||
|
||||
return new ResponseModel(); //things not comming from api
|
||||
return new ResponseModel(); // things not comming from api
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest) {
|
||||
LOGGER.info("Fetching Master Data Category-wise for ReqId={} and MID={}", masterRequest.getReqId(), masterRequest.getMid());
|
||||
LOGGER.info("Fetching Master Data CategoryResponseList-wise " + masterRequest);
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "FetchMasterDataCategoryWise";
|
||||
String requestId = masterRequest.getReqId();
|
||||
@@ -301,6 +310,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
}
|
||||
|
||||
BillerResponse responseWrapper = objectMapper.convertValue(dataMap, BillerResponse.class);
|
||||
List<BillerCategoryWise> savedEntities = mapperHelper.mapAndSaveAll(responseWrapper.getBillerResp(),
|
||||
requestId, txnID);
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -318,16 +330,15 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel getDispositionDetails(DispositionRequest dispositionDetailRequest) {
|
||||
LOGGER.info("Fetching Disposition Details for ReqId={} and MID={}", dispositionDetailRequest.getReqId(), dispositionDetailRequest.getMid());
|
||||
|
||||
LOGGER.info("Fetching Disposition Details for ReqId={} and MID={}", dispositionDetailRequest.getReqId(),
|
||||
dispositionDetailRequest.getMid());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "GetDispositionDetails";
|
||||
String requestId = dispositionDetailRequest.getReqId();
|
||||
helper.validateMerchant(dispositionDetailRequest.getMid());
|
||||
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, dispositionDetailRequest.getMid(),
|
||||
"GET", "N/A");
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
dispositionDetailRequest.getMid(), "GET", "N/A");
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||
@@ -337,7 +348,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
try {
|
||||
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
@@ -377,12 +388,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchCustomerParamGroup(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Customer Param Group for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
|
||||
LOGGER.info("Fetching Customer Param Group for ReqId={} and MID={}", requestModel.getReqId(),
|
||||
requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "FetchCustomerParamGroup";
|
||||
String requestId = requestModel.getReqId();
|
||||
@@ -415,6 +428,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
CustomerParamGroupsResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
CustomerParamGroupsDTO responseDTO = mapperHelper
|
||||
.saveCustomerParamGroups(responseWrapper.getCustomerParamGroupResp(), requestId, txnID);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
@@ -426,14 +442,15 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchAllMasterAmountOption(BillerDetailRequest requestModel) {
|
||||
|
||||
LOGGER.info("Fetching Master Data Amount List for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
|
||||
LOGGER.info("Fetching Master Data Amount List for ReqId={} and MID={}", requestModel.getReqId(),
|
||||
requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "FetchAllMasterAmountOption";
|
||||
String requestId = requestModel.getReqId();
|
||||
@@ -465,6 +482,10 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
}
|
||||
|
||||
AmountOptionsResponse responseWrapper = objectMapper.convertValue(dataMap, AmountOptionsResponse.class);
|
||||
|
||||
String saveAmountOptionsResponse = mapperHelper.saveAmountOptionsResponse(responseWrapper, requestId,
|
||||
txnID);
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -484,7 +505,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Plan Categories for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
|
||||
LOGGER.info("Fetching Plan Categories for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "FetchPlanCategorie";
|
||||
String requestId = requestModel.getReqId();
|
||||
@@ -516,6 +537,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
}
|
||||
|
||||
PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.class);
|
||||
|
||||
mapperHelper.saveCategoryItems(responseWrapper.getCategoryRespList(), requestId, txnID);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -529,12 +552,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchInitiatingChannel(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Initiating Channel for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
|
||||
LOGGER.info("Fetching Initiating Channel for ReqId={} and MID={}", requestModel.getReqId(),
|
||||
requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "FetchInitiatingChannel";
|
||||
String requestId = requestModel.getReqId();
|
||||
@@ -546,7 +571,6 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
|
||||
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
@@ -581,76 +605,70 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseModel fetchPlanByCategories(PlanRequest requestModel) {
|
||||
|
||||
LOGGER.info("Fetching Plan By Categories for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "FetchPlanByCategories";
|
||||
String requestId = requestModel.getReqId();
|
||||
LOGGER.info("Fetching Plan By Categories for ReqId={} and MID={}", requestModel.getReqId(),
|
||||
requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "FetchPlanByCategories";
|
||||
String requestId = requestModel.getReqId();
|
||||
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
|
||||
String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d",
|
||||
masterRegisterUrl,
|
||||
BBPSConstant.PLANS_URL,
|
||||
requestModel.getBillerId(),
|
||||
requestModel.getCategory() != null ? "&category=" + requestModel.getCategory() : "",
|
||||
requestModel.getAmountInRupees() != null ? "&amountInRupees=" + requestModel.getAmountInRupees() : "",
|
||||
requestModel.getCircle() != null ? "&circle=" + requestModel.getCircle() : "",
|
||||
requestModel.getPage(),
|
||||
requestModel.getPagesize()
|
||||
);
|
||||
String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d", masterRegisterUrl,
|
||||
BBPSConstant.PLANS_URL, requestModel.getBillerId(),
|
||||
requestModel.getCategory() != null ? "&category=" + requestModel.getCategory() : "",
|
||||
requestModel.getAmountInRupees() != null ? "&amountInRupees=" + requestModel.getAmountInRupees() : "",
|
||||
requestModel.getCircle() != null ? "&circle=" + requestModel.getCircle() : "", requestModel.getPage(),
|
||||
requestModel.getPagesize());
|
||||
|
||||
LOGGER.info("Calling Master API: {}", url);
|
||||
LOGGER.info("Calling Master API: {}", url);
|
||||
|
||||
// Convert request to JSON and create inbound & outbound logs
|
||||
String requestJson = helper.convertObjectToJson(requestModel);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||
// Convert request to JSON and create inbound & outbound logs
|
||||
String requestJson = helper.convertObjectToJson(requestModel);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||
try {
|
||||
Map<String, String> apiResponse = httpService.getRequest(url);
|
||||
String responseData = apiResponse.get("data");
|
||||
LOGGER.info("Response Data: {}", responseData);
|
||||
|
||||
try {
|
||||
Map<String, String> apiResponse = httpService.getRequest(url);
|
||||
String responseData = apiResponse.get("data");
|
||||
LOGGER.info("Response Data: {}", responseData);
|
||||
// Update outbound log with response
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
// Update outbound log with response
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
// Failure response
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
// Failure response
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(
|
||||
String.valueOf(dataMap.get("message")),
|
||||
String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks"))
|
||||
);
|
||||
}
|
||||
// Success response
|
||||
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
// Success response
|
||||
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
mapperHelper.savePlanResponse(responseWrapper, requestId, txnID);
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.billpaymentservice.bbps.swagger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Value("${swagger.server.url}")
|
||||
private String serverUrl;
|
||||
|
||||
@Value("${swagger.server.description}")
|
||||
private String serverDescription;
|
||||
|
||||
@Bean
|
||||
public OpenAPI openAPI() {
|
||||
return new OpenAPI()
|
||||
.info(new Info().title("BBPS API").description("Spring Boot REST API for BBPS System API Documentation")
|
||||
.version("1.0.0").contact(new Contact().name("BBPS ")))
|
||||
.servers(List.of(new Server().url(serverUrl).description(serverDescription)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
package com.billpaymentservice.bbps.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.AmountOptionDTO;
|
||||
import com.billpaymentservice.bbps.dto.BillerIconDTO;
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
|
||||
import com.billpaymentservice.bbps.dto.GroupDTO;
|
||||
import com.billpaymentservice.bbps.dto.MasterCategoryBillerResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.PlanResponse;
|
||||
import com.billpaymentservice.bbps.entites.AmountOptionByBillerId;
|
||||
import com.billpaymentservice.bbps.entites.AmountOptionDetails;
|
||||
import com.billpaymentservice.bbps.entites.BillerCategoryIcon;
|
||||
import com.billpaymentservice.bbps.entites.BillerCategoryWise;
|
||||
import com.billpaymentservice.bbps.entites.CategoryResponseList;
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamGroupById;
|
||||
import com.billpaymentservice.bbps.entites.FetchBillValidate;
|
||||
import com.billpaymentservice.bbps.entites.GroupParam;
|
||||
import com.billpaymentservice.bbps.entites.PlanResponses;
|
||||
import com.billpaymentservice.bbps.repository.AmountOptionByBillerIdRepository;
|
||||
import com.billpaymentservice.bbps.repository.BillerCategoryWiseRepository;
|
||||
import com.billpaymentservice.bbps.repository.CategoryResponseListRepository;
|
||||
import com.billpaymentservice.bbps.repository.CustomerParamGroupByBillerIdRepository;
|
||||
import com.billpaymentservice.bbps.repository.FetchBillValidateRepository;
|
||||
import com.billpaymentservice.bbps.repository.PlanResponseRepository;
|
||||
|
||||
@Component
|
||||
public class BillerMapperHelper {
|
||||
|
||||
private final BillerCategoryWiseRepository billerRepo;
|
||||
private final CustomerParamGroupByBillerIdRepository customerParamGroupByBillerIdRepo;
|
||||
private final AmountOptionByBillerIdRepository amountOptionByBillerIdRepository;
|
||||
private final PlanResponseRepository planResponseRepository;
|
||||
private final CategoryResponseListRepository categoryResponseListRepository;
|
||||
private final FetchBillValidateRepository fetchBillValidateRepository;
|
||||
|
||||
public BillerMapperHelper(BillerCategoryWiseRepository billerRepo,
|
||||
CustomerParamGroupByBillerIdRepository customerParamGroupByBillerIdRepo,
|
||||
AmountOptionByBillerIdRepository amountOptionByBillerIdRepository,
|
||||
PlanResponseRepository planResponseRepository,
|
||||
CategoryResponseListRepository categoryResponseListRepository,
|
||||
FetchBillValidateRepository fetchBillValidateRepository) {
|
||||
this.billerRepo = billerRepo;
|
||||
this.customerParamGroupByBillerIdRepo = customerParamGroupByBillerIdRepo;
|
||||
this.amountOptionByBillerIdRepository = amountOptionByBillerIdRepository;
|
||||
this.planResponseRepository = planResponseRepository;
|
||||
this.categoryResponseListRepository = categoryResponseListRepository;
|
||||
this.fetchBillValidateRepository = fetchBillValidateRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a list of MasterCategoryBillerResponse DTOs to entities, saves them, and
|
||||
* returns the saved list
|
||||
*/
|
||||
public List<BillerCategoryWise> mapAndSaveAll(List<MasterCategoryBillerResponse> dtos, String requestId,
|
||||
String txnId) {
|
||||
if (dtos == null || dtos.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<BillerCategoryWise> entities = new ArrayList<>();
|
||||
|
||||
for (MasterCategoryBillerResponse dto : dtos) {
|
||||
// Check if biller already exists
|
||||
BillerCategoryWise biller = billerRepo.findById(dto.getBillerId()).orElse(new BillerCategoryWise()); // create
|
||||
// Set/update fields
|
||||
biller.setBillerId(dto.getBillerId());
|
||||
biller.setBillerName(dto.getBillerName());
|
||||
biller.setBillerType(dto.getBillerType());
|
||||
biller.setBillerCategory(dto.getBillerCategory());
|
||||
biller.setBillerCoverage(dto.getBillerCoverage());
|
||||
biller.setBillerResponseType(dto.getBillerResponseType());
|
||||
biller.setBillerDescription(dto.getBillerDescription());
|
||||
biller.setPlanMDMRequirement(dto.getPlanMDMRequirement());
|
||||
biller.setAdhocBiller(dto.getAdhocBiller());
|
||||
biller.setPaymentAmountExactness(dto.getPaymentAmountExactness());
|
||||
biller.setCreateDateTime(new Date());
|
||||
biller.setRequestId(requestId);
|
||||
biller.setTxnId(txnId);
|
||||
|
||||
// Handle icon
|
||||
BillerIconDTO iconDTO = dto.getBiller_icon();
|
||||
if (iconDTO != null) {
|
||||
BillerCategoryIcon icon;
|
||||
if (biller.getIcon() != null) {
|
||||
icon = biller.getIcon(); // update existing icon
|
||||
} else {
|
||||
icon = new BillerCategoryIcon();
|
||||
icon.setBiller(biller);
|
||||
}
|
||||
icon.setIconData(iconDTO.getIcon_data());
|
||||
icon.setIconType(iconDTO.getIcon_type());
|
||||
biller.setIcon(icon); // set to biller
|
||||
}
|
||||
|
||||
entities.add(biller);
|
||||
}
|
||||
|
||||
// Save all at once
|
||||
return billerRepo.saveAll(entities);
|
||||
}
|
||||
|
||||
public CustomerParamGroupsDTO saveCustomerParamGroups(CustomerParamGroupsDTO dtos, String requestId, String txnId) {
|
||||
if (dtos == null || dtos.getGroups() == null || dtos.getGroups().isEmpty()) {
|
||||
return new CustomerParamGroupsDTO(); // Return empty DTO if no groups exist
|
||||
}
|
||||
|
||||
List<CustomerParamGroupById> entities = new ArrayList<>();
|
||||
|
||||
// Loop through the top-level groups and save them (including nested groups)
|
||||
for (GroupDTO groupDTO : dtos.getGroups()) {
|
||||
CustomerParamGroupById entity = saveGroupWithChildren(groupDTO, null, requestId, txnId); // null is for root
|
||||
// (no
|
||||
// parent group)
|
||||
entities.add(entity); // Add the saved entity to the list
|
||||
|
||||
}
|
||||
|
||||
// Save all entities at once using the repository
|
||||
List<CustomerParamGroupById> savedEntities = customerParamGroupByBillerIdRepo.saveAll(entities);
|
||||
|
||||
// Convert saved entities back into DTOs to return
|
||||
return convertEntitiesToDTO(savedEntities);
|
||||
}
|
||||
|
||||
private CustomerParamGroupById saveGroupWithChildren(GroupDTO groupDTO, CustomerParamGroupById parentGroup,
|
||||
String requestId, String txnId) {
|
||||
|
||||
// Create a new entity for the group
|
||||
CustomerParamGroupById groupEntity = new CustomerParamGroupById();
|
||||
groupEntity.setGroupId(groupDTO.getGroupId());
|
||||
groupEntity.setName(groupDTO.getName());
|
||||
groupEntity.setInput(groupDTO.getInput());
|
||||
groupEntity.setParentGroup(parentGroup); // Link to the parent group (if exists)
|
||||
groupEntity.setRequestId(requestId);
|
||||
groupEntity.setTxnId(txnId);
|
||||
groupEntity.setCreateDateTime(new Date());
|
||||
// Save group parameters (if any)
|
||||
if (groupDTO.getParams() != null && !groupDTO.getParams().isEmpty()) {
|
||||
List<GroupParam> groupParams = new ArrayList<>();
|
||||
for (String paramName : groupDTO.getParams()) {
|
||||
GroupParam param = new GroupParam();
|
||||
param.setParamName(paramName); // Set the parameter name (e.g., "Admission No")
|
||||
param.setGroup(groupEntity); // Link the parameter to the current group
|
||||
groupParams.add(param);
|
||||
}
|
||||
groupEntity.setParams(groupParams); // Link parameters to the group
|
||||
}
|
||||
|
||||
// Recursively save child groups if they exist
|
||||
if (groupDTO.getGroups() != null && !groupDTO.getGroups().isEmpty()) {
|
||||
List<CustomerParamGroupById> childEntities = new ArrayList<>();
|
||||
for (GroupDTO childGroupDTO : groupDTO.getGroups()) {
|
||||
CustomerParamGroupById childEntity = saveGroupWithChildren(childGroupDTO, groupEntity, requestId,
|
||||
txnId); // Pass
|
||||
// current
|
||||
// group
|
||||
// as
|
||||
// parent
|
||||
childEntities.add(childEntity);
|
||||
}
|
||||
groupEntity.setChildGroups(childEntities); // Set the child groups
|
||||
}
|
||||
|
||||
// Save the current group entity and return it
|
||||
return groupEntity;
|
||||
}
|
||||
|
||||
private CustomerParamGroupsDTO convertEntitiesToDTO(List<CustomerParamGroupById> savedEntities) {
|
||||
|
||||
if (savedEntities == null || savedEntities.isEmpty()) {
|
||||
// Return an empty or default DTO if no entities are found
|
||||
return new CustomerParamGroupsDTO(); // return an empty DTO object
|
||||
}
|
||||
|
||||
CustomerParamGroupsDTO responseDTO = new CustomerParamGroupsDTO();
|
||||
List<GroupDTO> savedGroups = new ArrayList<>();
|
||||
|
||||
// Convert each saved entity to DTO
|
||||
for (CustomerParamGroupById savedEntity : savedEntities) {
|
||||
GroupDTO groupDTO = new GroupDTO();
|
||||
groupDTO.setGroupId(savedEntity.getGroupId());
|
||||
groupDTO.setName(savedEntity.getName());
|
||||
groupDTO.setInput(savedEntity.getInput());
|
||||
|
||||
// Recursively map child groups if they exist
|
||||
if (savedEntity.getChildGroups() != null) {
|
||||
List<GroupDTO> childGroupDTOs = new ArrayList<>();
|
||||
for (CustomerParamGroupById childEntity : savedEntity.getChildGroups()) {
|
||||
GroupDTO childGroupDTO = new GroupDTO();
|
||||
childGroupDTO.setGroupId(childEntity.getGroupId());
|
||||
childGroupDTO.setName(childEntity.getName());
|
||||
childGroupDTO.setInput(childEntity.getInput());
|
||||
// childGroupDTO.setParams(childEntity.getParams()); // Set parameters of child
|
||||
// group
|
||||
childGroupDTOs.add(childGroupDTO);
|
||||
}
|
||||
groupDTO.setGroups(childGroupDTOs);
|
||||
}
|
||||
|
||||
// Add the DTO to the response
|
||||
savedGroups.add(groupDTO);
|
||||
}
|
||||
|
||||
responseDTO.setGroups(savedGroups);
|
||||
return responseDTO;
|
||||
}
|
||||
|
||||
// Method to save AmountOptionsResponse and AmountOption entities
|
||||
public String saveAmountOptionsResponse(AmountOptionsResponse responseWrapper, String requestId, String txnId) {
|
||||
// Convert AmountOptionsResponseDTO to AmountOptionsResponse entity
|
||||
|
||||
if (responseWrapper == null) {
|
||||
// Return an empty or default DTO if no entities are found
|
||||
return "Data Is Empty"; // return an empty DTO object
|
||||
}
|
||||
AmountOptionByBillerId entity = new AmountOptionByBillerId();
|
||||
entity.setAmountOptions(responseWrapper.getAmountOptions());
|
||||
|
||||
// Map AmountOptionDTO list to AmountOptionDetails entities
|
||||
List<AmountOptionDetails> amountOptionDetailsList = mapAmountOptionDTOToEntity(
|
||||
responseWrapper.getAmountOptionDAOS(), requestId, txnId);
|
||||
|
||||
// Set the mapped AmountOptionDetails list to AmountOptionByBillerId entity
|
||||
entity.setAmountOptionDetails(amountOptionDetailsList);
|
||||
entity.setCreateDateTime(new Date());
|
||||
|
||||
// Save AmountOptionByBillerId entity (this will also save related
|
||||
// AmountOptionDetails entities)
|
||||
amountOptionByBillerIdRepository.save(entity); // Saves the entity and cascades to AmountOptionDetails
|
||||
|
||||
// Return success message
|
||||
return "Data saved successfully!";
|
||||
}
|
||||
|
||||
private List<AmountOptionDetails> mapAmountOptionDTOToEntity(List<AmountOptionDTO> amountOptionDTOs,
|
||||
String requestId, String txnId) {
|
||||
|
||||
// If the list is null or empty, return an empty list of entities
|
||||
if (amountOptionDTOs == null || amountOptionDTOs.isEmpty()) {
|
||||
return new ArrayList<>(); // Return an empty list of AmountOptionDetails
|
||||
}
|
||||
|
||||
// AmountOptionDetails entities
|
||||
return amountOptionDTOs.stream().flatMap(dto ->
|
||||
// For each DTO, convert its breakup sets to AmountOptionDetails entities
|
||||
dto.getAmountBreakupSets().stream().map(breakup -> {
|
||||
// Create a new AmountOptionDetails entity for each breakup set
|
||||
AmountOptionDetails amountOptionDetails = new AmountOptionDetails();
|
||||
|
||||
// Set the breakup set as a separate entity (each breakup set becomes a new
|
||||
// record)
|
||||
amountOptionDetails.setAmountBreakupSet(breakup); // Store each breakup set as an individual record
|
||||
|
||||
// You can optionally set the amountOptionId here, if you want to link this
|
||||
// detail to the parent.
|
||||
// Assuming you want to set it directly here or pass it via the entity later:
|
||||
amountOptionDetails.setAmountOptionId(dto.getAmountOptionId());
|
||||
amountOptionDetails.setRequestId(requestId);
|
||||
amountOptionDetails.setTxnId(txnId);
|
||||
|
||||
// Return the mapped AmountOptionDetails entity
|
||||
return amountOptionDetails;
|
||||
})).collect(Collectors.toList()); // Collect them into a list and return
|
||||
}
|
||||
|
||||
public PlanResponses savePlanResponse(PlanResponse planResponseDTO, String requestId, String txnId) {
|
||||
|
||||
// If the list is null or empty, return an empty list of entities
|
||||
if (planResponseDTO == null) {
|
||||
return new PlanResponses(); // Return an empty list of AmountOptionDetails
|
||||
}
|
||||
|
||||
// Convert DTO to Entity using ModelMapper
|
||||
ModelMapper modelMapper = new ModelMapper();
|
||||
PlanResponses planResponseEntity = modelMapper.map(planResponseDTO, PlanResponses.class);
|
||||
// Save the entity to the database
|
||||
// Set the requestId and txnId in the entity
|
||||
planResponseEntity.setRequestId(requestId);
|
||||
planResponseEntity.setTxnId(txnId);
|
||||
planResponseEntity.setCreateDateTime(new Date());
|
||||
return planResponseRepository.save(planResponseEntity);
|
||||
}
|
||||
|
||||
public String saveCategoryItems(List<String> categoryRespList, String requestId, String txnId) {
|
||||
int savedCount = 0; // To track how many items were saved
|
||||
|
||||
if (categoryRespList == null || categoryRespList.isEmpty()) {
|
||||
return "No items to save.";
|
||||
}
|
||||
|
||||
for (String item : categoryRespList) {
|
||||
CategoryResponseList category = new CategoryResponseList();
|
||||
category.setCategoryRespList(item);
|
||||
category.setRequestId(txnId);
|
||||
category.setRequestId(requestId);
|
||||
category.setCreateDateTime(new Date());
|
||||
categoryResponseListRepository.save(category);
|
||||
savedCount++;
|
||||
}
|
||||
return savedCount + " items were successfully saved.";
|
||||
}
|
||||
|
||||
/*
|
||||
* public FetchBillValidate
|
||||
* saveFetchBillValidateResponse(FetchBillValidateResponse dto, String
|
||||
* requestId, String txnId) {
|
||||
*
|
||||
* if (dto == null) { return new FetchBillValidate(); }
|
||||
*
|
||||
* // Convert DTO to Entity FetchBillValidate entity = new FetchBillValidate();
|
||||
*
|
||||
* entity.setBillId(dto.getBillId()); entity.setRefId(dto.getRefId());
|
||||
* entity.setBillerId(dto.getBillerId()); entity.setStatus(dto.getStatus());
|
||||
* entity.setActionType(dto.getActionType()); entity.setUserId(dto.getUserId());
|
||||
* entity.setBillerResponse(dto.getBillerResponse());
|
||||
* entity.setAdditionalInfo(dto.getAdditionalInfo());
|
||||
* entity.setCustomerParams(dto.getCustomerParams());
|
||||
* entity.setPlanInfoDaos(dto.getPlanInfoDaos());
|
||||
* entity.setCreationDate(dto.getCreationDate());
|
||||
* entity.setModifiedDate(dto.getModifiedDate());
|
||||
* entity.setCreatedEpochDate(dto.getCreatedEpochDate());
|
||||
* entity.setModifiedEpochDate(dto.getModifiedEpochDate());
|
||||
* entity.setRequestId(requestId); entity.setTxnId(txnId);
|
||||
* entity.setCreateDateTime(new Date());
|
||||
*
|
||||
* // Save the entity in the database return
|
||||
* fetchBillValidateRepository.save(entity); }
|
||||
*/
|
||||
}
|
||||
@@ -9,10 +9,18 @@ spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||
spring.jpa.properties.hibernate.default_schema=public
|
||||
|
||||
#swagger.server.url=https://procurelinc.in/BBPS
|
||||
#swagger.server.description=Production Server
|
||||
|
||||
swagger.server.url=http://192.168.1.24:9090
|
||||
|
||||
swagger.server.description=Local Development Server
|
||||
|
||||
|
||||
# DataSource
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
|
||||
spring.datasource.username=postgres
|
||||
|
||||
spring.datasource.password=himanshu@123
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
|
||||
|
||||
Reference in New Issue
Block a user