first commit

This commit is contained in:
himanshu
2025-10-24 17:16:53 +05:30
parent 988fc8edca
commit 948e508d0c
25 changed files with 1070 additions and 1 deletions
@@ -0,0 +1,16 @@
package com.billpaymentservice.bbps;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication
@EnableAsync
public class BbpsApplication {
public static void main(String[] args) {
SpringApplication.run(BbpsApplication.class, args);
}
}
@@ -0,0 +1,13 @@
package com.billpaymentservice.bbps;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(BbpsApplication.class);
}
}
@@ -0,0 +1,44 @@
package com.billpaymentservice.bbps.audit;
import java.io.Serializable;
import java.util.Date;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import lombok.Data;
@Data
@MappedSuperclass
public abstract class Auditable<U> implements Serializable {
private static final long serialVersionUID = 1L;
@CreatedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "create_date_time")
protected Date createDateTime;
@LastModifiedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updated_date_time")
protected Date updatedDateTime;
@LastModifiedBy
@Column(name = "updated_by")
protected U updatedBy;
@CreatedBy
@Column(name = "create_by")
protected U createdBy;
@Column(name = "is_deleted")
protected boolean isDeleted = false;
}
@@ -0,0 +1,17 @@
package com.billpaymentservice.bbps.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Service;
import lombok.Getter;
import lombok.Setter;
@Service
@ConfigurationProperties(prefix = "certificate")
@Getter
@Setter
public class CertificateConfig {
private String path;
private String password;
}
@@ -0,0 +1,47 @@
package com.billpaymentservice.bbps.config;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
// ✅ Timeout config
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(Timeout.ofSeconds(5)) // pool wait
.setConnectTimeout(Timeout.ofSeconds(5)) // TCP connect
.setResponseTimeout(Timeout.ofSeconds(10)) // response read
.build();
// ✅ Connection pool manager (HttpClient5 style)
var connManager = PoolingHttpClientConnectionManagerBuilder.create()
.setMaxConnTotal(200)
.setMaxConnPerRoute(50)
.build();
// ✅ Build HttpClient
CloseableHttpClient httpClient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.setConnectionManager(connManager)
.disableAutomaticRetries()
.evictExpiredConnections()
.evictIdleConnections(TimeValue.ofSeconds(30))
.build();
// ✅ Bind RestTemplate with HttpClient
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
factory.setBufferRequestBody(true);
return new RestTemplate(factory);
}
}
@@ -0,0 +1,24 @@
package com.billpaymentservice.bbps.controller;
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.request.BillerDetailRequest;
import com.billpaymentservice.bbps.service.MasterDataService;
@RestController
public class MasterDataController {
private final MasterDataService masterDataService;
public MasterDataController(MasterDataService masterDataService) {
this.masterDataService = masterDataService;
}
@PostMapping("/getBillerById")
public String getBillerById(@RequestBody BillerDetailRequest billerRequestRequest) {
masterDataService.getBillerByBillerId(billerRequestRequest);
return "Abc";
}
}
@@ -0,0 +1,17 @@
package com.billpaymentservice.bbps.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Detail {
private String name;
private String value;
}
@@ -0,0 +1,16 @@
package com.billpaymentservice.bbps.dto;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class DeviceDetail {
private List<Detail> detail;
}
@@ -0,0 +1,9 @@
package com.billpaymentservice.bbps.dto.request;
import com.billpaymentservice.bbps.entites.BaseClass;
public class BillerDetailRequest extends BaseClass{
private String billerId;
}
@@ -0,0 +1,5 @@
package com.billpaymentservice.bbps.dto.response;
public class BillerDataResponse {
}
@@ -0,0 +1,21 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.dto.DeviceDetail;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class BaseClass {
private String mid;
private String secretKey;
private String txnId;
private DeviceDetail deviceDetial;
}
@@ -0,0 +1,21 @@
package com.billpaymentservice.bbps.exception;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CustomException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
String message;
public CustomException( String message) {
super();
this.message = message;
}
}
@@ -0,0 +1,13 @@
package com.billpaymentservice.bbps.exception;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class GlobalExceptionHandler {
}
@@ -0,0 +1,10 @@
package com.billpaymentservice.bbps.service;
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
public interface MasterDataService {
public BillerDataResponse getBillerByBillerId(BillerDetailRequest billerDetailRequest);
}
@@ -0,0 +1,14 @@
package com.billpaymentservice.bbps.serviceImpl;
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
import com.billpaymentservice.bbps.service.MasterDataService;
public class MasterDataServiceImpl implements MasterDataService {
@Override
public BillerDataResponse getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
// TODO Auto-generated method stub
return null;
}
}
@@ -0,0 +1,5 @@
package com.billpaymentservice.bbps.util;
public class BBPSConstant {
}