diff --git a/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Controller/SessionDetailsController.java b/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Controller/SessionDetailsController.java index 3af7d87..686a268 100644 --- a/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Controller/SessionDetailsController.java +++ b/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Controller/SessionDetailsController.java @@ -1,6 +1,7 @@ package com.ondc.yugabyte_integration.Controller; import com.ondc.yugabyte_integration.Entity.Payload; +import com.ondc.yugabyte_integration.Entity.PayloadDetailsDTO; import com.ondc.yugabyte_integration.Entity.SessionDetails; import com.ondc.yugabyte_integration.Repository.PayloadRepository; import com.ondc.yugabyte_integration.Repository.SessionDetailsRepository; @@ -66,11 +67,8 @@ public SessionDetails createSession(@RequestBody SessionDetails sessionDetails) } @GetMapping("/payload/{sessionId}") - public List getPayloadBySessionId(@PathVariable String sessionId) { - SessionDetails sessionDetails = sdRepository.findBySessionId(sessionId) - .orElseThrow(() -> new RuntimeException("SessionDetails not found for sessionId: " + sessionId)); - ; - return sessionDetails.getPayloads(); + public List getPayloadBySessionId(@PathVariable String sessionId) { + return sessionDetailsService.getPayloadDetails(sessionId); } @PutMapping("/{sessionId}") diff --git a/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Entity/PayloadDetailsDTO.java b/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Entity/PayloadDetailsDTO.java new file mode 100644 index 0000000..ed4342a --- /dev/null +++ b/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Entity/PayloadDetailsDTO.java @@ -0,0 +1,39 @@ +package com.ondc.yugabyte_integration.Entity; + +import java.util.List; + +public class PayloadDetailsDTO { + private SessionDetails.Type npType; + private String domain; + private Payload payloads; + + public PayloadDetailsDTO(SessionDetails.Type npType, String domain, Payload payloads) { + this.npType = npType; + this.domain = domain; + this.payloads = payloads; + } + + public SessionDetails.Type getNpType() { + return npType; + } + + public void setNpType(SessionDetails.Type npType) { + this.npType = npType; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public Payload getPayloads() { + return payloads; + } + + public void setPayloads(Payload payloads) { + this.payloads = payloads; + } +} diff --git a/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Service/SessionDetailsService.java b/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Service/SessionDetailsService.java index 3e0c7bb..b2a1ca2 100644 --- a/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Service/SessionDetailsService.java +++ b/yugabyte-integration/src/main/java/com/ondc/yugabyte_integration/Service/SessionDetailsService.java @@ -1,11 +1,15 @@ package com.ondc.yugabyte_integration.Service; +import com.ondc.yugabyte_integration.Entity.Payload; +import com.ondc.yugabyte_integration.Entity.PayloadDetailsDTO; import com.ondc.yugabyte_integration.Entity.SessionDetails; import com.ondc.yugabyte_integration.Repository.SessionDetailsRepository; import jakarta.transaction.Transactional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; + +import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -60,4 +64,15 @@ public void deleteSession(String sessionId) { public Optional getSessionWithPayloads(String sessionId) { return sessionDetailsRepository.findWithPayloadsBySessionId(sessionId); } + + public List getPayloadDetails(String sessionId) { + SessionDetails sessionDetails = sessionDetailsRepository.findBySessionId(sessionId) + .orElseThrow(() -> new RuntimeException("SessionDetails not found for sessionId: " + sessionId)); + + List payloadDetailsDTOS = new ArrayList<>(); + for (Payload payload : sessionDetails.getPayloads()) { + payloadDetailsDTOS.add(new PayloadDetailsDTO(sessionDetails.getNpType(), sessionDetails.getDomain(), payload)); + } + return payloadDetailsDTOS; + } } diff --git a/yugabyte-integration/target/classes/application.properties b/yugabyte-integration/target/classes/application.properties index 7c62a07..4713c0c 100644 --- a/yugabyte-integration/target/classes/application.properties +++ b/yugabyte-integration/target/classes/application.properties @@ -2,7 +2,7 @@ spring.application.name=yugabyte-integration #spring.datasource.url=${DB_URL} spring.datasource.url=jdbc:postgresql://127.0.0.1:5433/my_app spring.datasource.username=yugabyte -spring.datasource.password= +#spring.datasource.password= #spring.datasource.password=${DB_PASSWORD} spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect spring.jpa.hibernate.ddl-auto=update diff --git a/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Controller/SessionDetailsController.class b/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Controller/SessionDetailsController.class index 79528ba..94d25c3 100644 Binary files a/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Controller/SessionDetailsController.class and b/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Controller/SessionDetailsController.class differ diff --git a/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Entity/PayloadDetailsDTO.class b/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Entity/PayloadDetailsDTO.class new file mode 100644 index 0000000..6355e8f Binary files /dev/null and b/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Entity/PayloadDetailsDTO.class differ diff --git a/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Service/SessionDetailsService.class b/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Service/SessionDetailsService.class index 9a19589..55946c5 100644 Binary files a/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Service/SessionDetailsService.class and b/yugabyte-integration/target/classes/com/ondc/yugabyte_integration/Service/SessionDetailsService.class differ