moved some mapper code from helper to billerMapper

This commit is contained in:
Lincpay Tech
2025-11-24 16:34:55 +05:30
parent d8d8bdc3d3
commit c9dfb6f9ba
5 changed files with 247 additions and 217 deletions
@@ -3,7 +3,6 @@ package com.billpaymentservice.bbps.serviceImpl;
import java.util.Map;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -88,7 +87,7 @@ public class AgentServiceImpl implements AgentService {
fetchBillRequest.setClientReqId(txnId);
helper.validateMerchant(fetchBillRequest.getMid());
FetchBillForwardRequest forwardReq = helper.fetchBillForwardRequestMap(fetchBillRequest);
FetchBillForwardRequest forwardReq = mapperHelper.fetchBillForwardRequestMap(fetchBillRequest);
String forwardJson = helper.convertObjectToJson(forwardReq);
String requestJson = helper.convertObjectToJson(fetchBillRequest);
@@ -127,7 +126,7 @@ public class AgentServiceImpl implements AgentService {
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
BillInitiate billInitiate = new BillInitiate();
billInitiate.setBillId((String) dataMap.get("billId"));
@@ -196,7 +195,7 @@ public class AgentServiceImpl implements AgentService {
LOGGER.info("Current Bill Status: {}", status);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
helper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
mapperHelper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
LOGGER.info("Bill data saved successfully for billId: {}", billId);
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
@@ -252,7 +251,7 @@ public class AgentServiceImpl implements AgentService {
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
helper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
mapperHelper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus());
return responseModel;
@@ -276,7 +275,7 @@ public class AgentServiceImpl implements AgentService {
fetchBillValidateRequest.setClientReqId(txnId);
helper.validateMerchant(fetchBillValidateRequest.getMid());
FetchBillValidatestForwardRequest forwardReq = helper
FetchBillValidatestForwardRequest forwardReq = mapperHelper
.fetchBillValidatestForwardRequest(fetchBillValidateRequest);
String forwardJson = helper.convertObjectToJson(forwardReq);
@@ -388,7 +387,7 @@ public class AgentServiceImpl implements AgentService {
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
System.out.println("responseWrapper:" + responseWrapper);
helper.saveBillValidation(responseWrapper, billRequest);
mapperHelper.saveBillValidation(responseWrapper, billRequest);
LOGGER.info("Bill data saved successfully for billId: {}", billId);
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
@@ -441,7 +440,7 @@ public class AgentServiceImpl implements AgentService {
GeneralResp generalResp = responseWrapper.getGenericResponse();
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
helper.saveBillValidation(responseWrapper, billRequest);
mapperHelper.saveBillValidation(responseWrapper, billRequest);
LOGGER.info("Bill validation saved successfully for billId: {}", billId);
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
@@ -200,7 +200,7 @@ public class MasterDataServiceImpl implements MasterDataService {
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
BillerDetails entity = mapper.map(responseWrapper.getBillerDAO(), BillerDetails.class);
EntityRelationshipUtil.linkBillerRelationships(entity);// linking nesting entity foreign key
helper.saveOrUpdateBillerData(entity);
mapperHelper.saveOrUpdateBillerData(entity);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
@@ -37,6 +37,7 @@ import com.billpaymentservice.bbps.repository.PaymentRepository;
import com.billpaymentservice.bbps.repository.TransactionMasterRepository;
import com.billpaymentservice.bbps.service.PaymentService;
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.annotation.JsonInclude;
@@ -59,7 +60,7 @@ public class PaymentServiceImpl implements PaymentService {
private final PaymentIntiateRepository paymentIntiateRepository;
private final TransactionMasterRepository transactionMasterRepository;
private final AgentFundTransferRepository agentFundTransferRepository;
private final BillerMapperHelper mapperHelper;
// Shared reusable instances
private final ObjectMapper objectMapper;
private final ModelMapper modelMapper;
@@ -70,7 +71,8 @@ public class PaymentServiceImpl implements PaymentService {
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository,
TransactionMasterRepository transactionMasterRepository,
AgentFundTransferRepository agentFundTransferRepository) {
AgentFundTransferRepository agentFundTransferRepository,
BillerMapperHelper mapperHelper) {
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
this.httpService = httpService;
this.helper = helper;
@@ -80,6 +82,7 @@ public class PaymentServiceImpl implements PaymentService {
this.paymentIntiateRepository = paymentIntiateRepository;
this.transactionMasterRepository = transactionMasterRepository;
this.agentFundTransferRepository = agentFundTransferRepository;
this.mapperHelper = mapperHelper;
this.objectMapper = new ObjectMapper();
this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
@@ -100,7 +103,7 @@ public class PaymentServiceImpl implements PaymentService {
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
HttpHeaders headers = helper.buildHeaders(headersData);
BillPaymentForwardRequest forwardReq = helper.billPaymentForwardRequest(billPaymentRequest);
BillPaymentForwardRequest forwardReq = mapperHelper.billPaymentForwardRequest(billPaymentRequest);
String forwardjson = helper.convertObjectToJson(forwardReq);
String requestJson = helper.convertObjectToJson(billPaymentRequest);