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 {
}
+40
View File
@@ -0,0 +1,40 @@
spring.application.name=bbps
# JPA & Hibernate
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
# DataSource
spring.datasource.url=jdbc:postgresql://localhost:5432/personalPractice
spring.datasource.username=postgres
spring.datasource.password=Admin123
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
# HikariCP settings
spring.datasource.hikari.connection-timeout=10000
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.maximum-pool-size=50
spring.datasource.hikari.idle-timeout=2000000
spring.datasource.hikari.max-lifetime=110000
spring.datasource.hikari.auto-commit=true
# Server port
server.port=8086
# Logging levels
logging.level.io.github.resilience4j.retry=DEBUG
# Certificate
certificate.path=D:/Switch Document/rbl_lincpay/rbl_lincpay.pfx
certificate.password=lincpay
# NPCI URLs
npci.respPay.url=https://globalcertzone.npci.org.in:443/imps/RespPay/2.0/urn:txnid:
npci.respChkTxn.url=https://globalcertzone.npci.org.in:443/imps/RespChkTxn/2.0/urn:txnid:
npci.respValAdd.url=https://globalcertzone.npci.org.in:443/imps/RespValAdd/2.0/urn:txnid:
npci.ack.schemas=src/main/resources/schemas/imps_ack.xsd
# Resilience4j Retry
resilience4j.retry.instances.callbackService.max-attempts=1
resilience4j.retry.instances.callbackService.wait-duration=2s
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://npci.org/upi/schema/"
xmlns:ns2="http://npci.org/upi/schema/"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<!-- Root element -->
<xs:element name="Ack">
<xs:complexType>
<!-- Attributes of Ack -->
<xs:attribute name="api" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<!-- Allowed API values -->
<xs:enumeration value="ReqPay"/>
<xs:enumeration value="ReqChkTxn"/>
<xs:enumeration value="ReqValAdd"/>
<xs:enumeration value="ReqListAccPvd"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="reqMsgId" type="xs:string" use="required"/>
<xs:attribute name="ts" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,13 @@
package com.lincpay.bbps;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class BbpsApplicationTests {
@Test
void contextLoads() {
}
}