adding FetchbillByBillId

This commit is contained in:
himanshu
2025-10-27 10:48:19 +05:30
parent 33d80218b4
commit cde8b79d53
24 changed files with 568 additions and 41 deletions
@@ -1,24 +1,70 @@
package com.billpaymentservice.bbps.controller;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
import com.billpaymentservice.bbps.service.MasterDataService;
@RestController
public class MasterDataController {
private final MasterDataService masterDataService;
private static final Logger log = LoggerFactory.getLogger(MasterDataController.class);
public MasterDataController(MasterDataService masterDataService) {
this.masterDataService = masterDataService;
}
@PostMapping(value = "/getBillerDetails",
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<BillerDataResponse> getBillerDetails(
@Validated @RequestBody BillerDetailRequest billerDetailRequest) {
@PostMapping("/getBillerById")
public String getBillerById(@RequestBody BillerDetailRequest billerRequestRequest) {
masterDataService.getBillerByBillerId(billerRequestRequest);
return "Abc";
log.info("Received biller details request for billerId: {}", billerDetailRequest.getBillerId());
BillerDataResponse response = masterDataService.getBillerByBillerId(billerDetailRequest);
HttpStatus status;
String statusCode = response.getGeneralResp() != null ? response.getGeneralResp().getStatusCode() : "500";
switch (statusCode) {
case "200":
status = HttpStatus.OK;
break;
case "404":
status = HttpStatus.NOT_FOUND;
break;
case "500":
status = HttpStatus.INTERNAL_SERVER_ERROR;
break;
default:
status = HttpStatus.BAD_REQUEST;
break;
}
log.info("Returning response for billerId: {} with HTTP status: {}", billerDetailRequest.getBillerId(), status);
return new ResponseEntity<>(response, status);
}
}
}