Merge pull request 'feature3' (#15) from feature3 into develop
Reviewed-on: https://git.zeptic.in/himanshu/bbps/pulls/15
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
package com.billpaymentservice.bbps.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ContactMaster {
|
||||
private String mobNo;
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String tenantId;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ContactMasterRequest {
|
||||
private String category;
|
||||
private String tenantId;
|
||||
public class ContactMasterRequest extends BaseClass {
|
||||
private String category;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,4 @@ public class GetTicketLatestStausRequest extends BaseClass {
|
||||
@NotBlank(message = "ticketId Id cannot be null or blank")
|
||||
private String ticketId;
|
||||
|
||||
|
||||
private String tenantId;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.billpaymentservice.bbps.dto.response;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ContactMaster;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@@ -15,10 +16,12 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ContactMasterResponse {
|
||||
|
||||
private GeneralResp generalResp;
|
||||
private List<ContactMaster> contactMasterList;
|
||||
|
||||
}
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private GeneralResp generalResp;
|
||||
private List<ContactMaster> contactMasterList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
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;
|
||||
|
||||
@Entity
|
||||
@Table(name = "contact_master_data")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ContactMasterData extends Auditable<String> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "mob_no")
|
||||
private String mobNo;
|
||||
|
||||
@Column(name = "req_id")
|
||||
private String reqId;
|
||||
|
||||
@Column(name = "txn_id")
|
||||
private String txnId;
|
||||
}
|
||||
@@ -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.ContactMasterData;
|
||||
|
||||
@Repository
|
||||
public interface ContactMasterDataRepository extends JpaRepository<ContactMasterData, Long> {
|
||||
|
||||
}
|
||||
@@ -91,6 +91,8 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String requestId = complainRequestDTO.getReqId();
|
||||
String fullUrl = complainDataUrl + BBPSConstant.ADD_COMPLAIN_ENDPOINT;
|
||||
|
||||
LOGGER.info("Full URL-: "+ fullUrl);
|
||||
|
||||
// Convert input DTO to JSON
|
||||
String requestJson = helper.convertObjectToJson(complainRequestDTO);
|
||||
|
||||
@@ -194,8 +196,14 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
try {
|
||||
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, requestJson, headers);
|
||||
ObjectNode root = (ObjectNode) objectMapper.readTree(requestJson);
|
||||
root.put("tenantId", headersData.getTenantId());
|
||||
//root.put("agentId", headersData.getAgentId());
|
||||
|
||||
String finalJson = root.toString();
|
||||
LOGGER.info("Final Request Sent to API: {}", finalJson);
|
||||
// LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
||||
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// java
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -13,6 +12,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ContactMaster;
|
||||
import com.billpaymentservice.bbps.dto.CustomParamDTO;
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
@@ -29,6 +29,7 @@ import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillerResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ChannelsListResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ContactMasterResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.CustomParamResp;
|
||||
import com.billpaymentservice.bbps.dto.response.CustomerParamGroupsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.DispositionResponse;
|
||||
@@ -42,7 +43,6 @@ import com.billpaymentservice.bbps.entites.CustomParam;
|
||||
import com.billpaymentservice.bbps.entites.DispositionDetails;
|
||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.TicketDispositionDetails;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
||||
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
||||
@@ -51,7 +51,6 @@ import com.billpaymentservice.bbps.repository.DispositionRepository;
|
||||
import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
|
||||
import com.billpaymentservice.bbps.repository.MerchantRepository;
|
||||
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
|
||||
import com.billpaymentservice.bbps.repository.TicketDispositionRepository;
|
||||
import com.billpaymentservice.bbps.service.MasterDataService;
|
||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
||||
@@ -73,7 +72,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
private MerchantRepository merchantRegisterRepo;
|
||||
private HttpClientApi httpClientApi;
|
||||
private final DispositionRepository dispositionRepository;
|
||||
|
||||
|
||||
private final Helper helper;
|
||||
private final BillerDataRepository billerDataRespository;
|
||||
private final HttpService httpService;
|
||||
@@ -98,7 +97,6 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
||||
this.mapperHelper = mapperHelper;
|
||||
this.customParamReposiotory = customParamReposiotory;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -173,8 +171,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String requestJson = helper.convertObjectToJson(billerDetailRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
|
||||
System.out.println( billerDataRespository.findByBillerId(billerId));
|
||||
|
||||
System.out.println(billerDataRespository.findByBillerId(billerId));
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
@@ -275,8 +273,60 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
|
||||
LOGGER.info("Fetching Contact Master Request Data " + contactMasterRequest);
|
||||
|
||||
return new ResponseModel(); // things not comming from api
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "FetchMasterDataCategoryWise";
|
||||
String requestId = contactMasterRequest.getReqId();
|
||||
String requestJson = helper.convertObjectToJson(contactMasterRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, contactMasterRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
try {
|
||||
helper.validateMerchant(contactMasterRequest.getMid());
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
String fullUrl = masterRegisterUrl + String.format(BBPSConstant.CONTACT_MASTER_URL,
|
||||
headersData.getTenantId(), contactMasterRequest.getCategory());
|
||||
|
||||
LOGGER.info("Contact Master Full URL-:" + fullUrl);
|
||||
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);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
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")) // remarks
|
||||
);
|
||||
}
|
||||
|
||||
ContactMasterResponse responseWrapper = objectMapper.convertValue(dataMap, ContactMasterResponse.class);
|
||||
String result = mapperHelper.saveContactMasterData(responseWrapper.getContactMasterList(), requestId,
|
||||
txnID);
|
||||
|
||||
LOGGER.info("Result Master Contact Data -:" + result);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ public class BBPSConstant {
|
||||
|
||||
public static final String BILLER_URL = "/billers";
|
||||
public static final String MASTER_CATEGORY_URL = "/categories-master?tenantId=";
|
||||
public static final String CONTACT_MASTER_URL = "/contact-master?tenantId=%s&category=%s";
|
||||
|
||||
public static final String CUSTOMER_PARAM_GROUP = "/customerParamGroup?billerId=";
|
||||
public static final String AMOUNT_OPTIONS = "/amountOptions?billerId=";
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.billpaymentservice.bbps.dto.BillCustomerParamsDTO;
|
||||
import com.billpaymentservice.bbps.dto.BillerIconDTO;
|
||||
import com.billpaymentservice.bbps.dto.CheckClientBillerResponseDTO;
|
||||
import com.billpaymentservice.bbps.dto.ComplaintHistoryDTO;
|
||||
import com.billpaymentservice.bbps.dto.ContactMaster;
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
|
||||
import com.billpaymentservice.bbps.dto.Detail;
|
||||
import com.billpaymentservice.bbps.dto.GroupDTO;
|
||||
@@ -32,8 +33,8 @@ import com.billpaymentservice.bbps.dto.response.ClientReqIdResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.PlanResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
|
||||
import com.billpaymentservice.bbps.entites.AdditionalInfoPlans;
|
||||
import com.billpaymentservice.bbps.entites.AmountOptionByBillerId;
|
||||
@@ -49,6 +50,7 @@ import com.billpaymentservice.bbps.entites.CheckClientStatusReqId;
|
||||
import com.billpaymentservice.bbps.entites.ComplainStatus;
|
||||
import com.billpaymentservice.bbps.entites.ComplaintHistory;
|
||||
import com.billpaymentservice.bbps.entites.ComplaintStatusDetails;
|
||||
import com.billpaymentservice.bbps.entites.ContactMasterData;
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamGroupById;
|
||||
import com.billpaymentservice.bbps.entites.GroupParam;
|
||||
import com.billpaymentservice.bbps.entites.Plan;
|
||||
@@ -66,6 +68,7 @@ import com.billpaymentservice.bbps.repository.ClientReqIdRepository;
|
||||
import com.billpaymentservice.bbps.repository.ComplainDetailRepository;
|
||||
import com.billpaymentservice.bbps.repository.ComplaintHistoryRepository;
|
||||
import com.billpaymentservice.bbps.repository.ComplaintStatusRepository;
|
||||
import com.billpaymentservice.bbps.repository.ContactMasterDataRepository;
|
||||
import com.billpaymentservice.bbps.repository.CustomerParamGroupByBillerIdRepository;
|
||||
import com.billpaymentservice.bbps.repository.FetchBillValidateRepository;
|
||||
import com.billpaymentservice.bbps.repository.PlanResponseRepository;
|
||||
@@ -92,6 +95,7 @@ public class BillerMapperHelper {
|
||||
private final ComplainDetailRepository complainDetailRepository;
|
||||
private final CheckClientBillerDataRepository checkClientBillerDataRepository;
|
||||
private final ViewAllComplainTicketDetailRepository viewAllComplainTicketDetailRepository;
|
||||
private final ContactMasterDataRepository contactMasterDataRepository;
|
||||
|
||||
public BillerMapperHelper(BillerCategoryWiseRepository billerRepo,
|
||||
CustomerParamGroupByBillerIdRepository customerParamGroupByBillerIdRepo,
|
||||
@@ -104,7 +108,8 @@ public class BillerMapperHelper {
|
||||
ClientReqIdRepository clientReqIdRepository,
|
||||
CheckClientBillerDataRepository checkClientBillerDataRepository,
|
||||
TicketDispositionRepository ticketDispositionRepository,
|
||||
ViewAllComplainTicketDetailRepository viewAllComplainTicketDetailRepository) {
|
||||
ViewAllComplainTicketDetailRepository viewAllComplainTicketDetailRepository,
|
||||
ContactMasterDataRepository contactMasterDataRepository) {
|
||||
this.billerRepo = billerRepo;
|
||||
this.customerParamGroupByBillerIdRepo = customerParamGroupByBillerIdRepo;
|
||||
this.amountOptionByBillerIdRepository = amountOptionByBillerIdRepository;
|
||||
@@ -119,6 +124,7 @@ public class BillerMapperHelper {
|
||||
this.checkClientBillerDataRepository = checkClientBillerDataRepository;
|
||||
this.ticketDispositionRepository = ticketDispositionRepository;
|
||||
this.viewAllComplainTicketDetailRepository = viewAllComplainTicketDetailRepository;
|
||||
this.contactMasterDataRepository = contactMasterDataRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -794,4 +800,26 @@ public class BillerMapperHelper {
|
||||
return "SUCCESS";
|
||||
}
|
||||
|
||||
public String saveContactMasterData(List<ContactMaster> contactMasterList, String requestId, String txnID) {
|
||||
|
||||
if (contactMasterList == null || contactMasterList.isEmpty()) {
|
||||
return "No contact master data found";
|
||||
}
|
||||
|
||||
// Convert DTO → Entity
|
||||
List<ContactMasterData> entities = contactMasterList.stream().map(dto -> {
|
||||
ContactMasterData entity = new ContactMasterData();
|
||||
entity.setMobNo(dto.getMobNo());
|
||||
entity.setReqId(requestId);
|
||||
entity.setTxnId(txnID);
|
||||
entity.setCreateDateTime(new Date());
|
||||
return entity;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// Save list in DB
|
||||
contactMasterDataRepository.saveAll(entities);
|
||||
|
||||
return "Contact Master Saved Successfully";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user