-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(query): create common interface for search
- Loading branch information
1 parent
6316c79
commit d17672c
Showing
5 changed files
with
133 additions
and
4 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/it/pagopa/ecommerce/helpdesk/dataproviders/TransactionDataProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package it.pagopa.ecommerce.helpdesk.dataproviders | ||
|
||
import it.pagopa.generated.ecommerce.helpdesk.model.HelpDeskSearchTransactionRequestDto | ||
import it.pagopa.generated.ecommerce.helpdesk.model.TransactionResultDto | ||
import reactor.core.publisher.Mono | ||
|
||
/** | ||
* Transaction data provider interface. This interface models common function for transaction data | ||
* provider in order to search for transactions given a specific HelpDeskSearchTransactionRequestDto | ||
* criteria | ||
* | ||
* @see HelpDeskSearchTransactionRequestDto | ||
*/ | ||
interface TransactionDataProvider { | ||
|
||
/** Retrieve total record count for the given search criteria */ | ||
fun totalRecorcCount(searchCriteria: HelpDeskSearchTransactionRequestDto): Mono<Int> | ||
|
||
/** | ||
* Perform paginated query for retrieve transaction information for the given search criteria | ||
*/ | ||
fun findResult( | ||
searchCriteria: HelpDeskSearchTransactionRequestDto, | ||
offset: Int, | ||
limit: Int | ||
): Mono<List<TransactionResultDto>> | ||
} |
43 changes: 43 additions & 0 deletions
43
...tlin/it/pagopa/ecommerce/helpdesk/dataproviders/mongo/EcommerceTransactionDataProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package it.pagopa.ecommerce.helpdesk.dataproviders.mongo | ||
|
||
import it.pagopa.ecommerce.helpdesk.dataproviders.TransactionDataProvider | ||
import it.pagopa.generated.ecommerce.helpdesk.model.* | ||
import org.springframework.stereotype.Component | ||
import reactor.core.publisher.Mono | ||
|
||
@Component | ||
class EcommerceTransactionDataProvider() : TransactionDataProvider { | ||
|
||
override fun totalRecorcCount(searchCriteria: HelpDeskSearchTransactionRequestDto): Mono<Int> = | ||
when (searchCriteria) { | ||
is SearchTransactionRequestPaymentTokenDto -> Mono.just(0) // TODO implementare | ||
is SearchTransactionRequestRptIdDto -> Mono.just(0) // TODO implementare | ||
is SearchTransactionRequestTransactionIdDto -> Mono.just(0) // TODO implementare | ||
is SearchTransactionRequestEmailDto -> Mono.just(0) | ||
is SearchTransactionRequestFiscalCodeDto -> Mono.just(0) | ||
else -> | ||
Mono.error( | ||
RuntimeException("Unhandled search criteria ${searchCriteria.javaClass}") | ||
) | ||
} | ||
|
||
override fun findResult( | ||
searchCriteria: HelpDeskSearchTransactionRequestDto, | ||
offset: Int, | ||
limit: Int | ||
): Mono<List<TransactionResultDto>> = | ||
when (searchCriteria) { | ||
is SearchTransactionRequestPaymentTokenDto -> | ||
Mono.just(listOf(TransactionResultDto())) // TODO implementare | ||
is SearchTransactionRequestRptIdDto -> | ||
Mono.just(listOf(TransactionResultDto())) // TODO implementare | ||
is SearchTransactionRequestTransactionIdDto -> | ||
Mono.just(listOf(TransactionResultDto())) // TODO implementare | ||
is SearchTransactionRequestEmailDto -> Mono.just(listOf(TransactionResultDto())) | ||
is SearchTransactionRequestFiscalCodeDto -> Mono.just(listOf(TransactionResultDto())) | ||
else -> | ||
Mono.error( | ||
RuntimeException("Unhandled search criteria ${searchCriteria.javaClass}") | ||
) | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...ain/kotlin/it/pagopa/ecommerce/helpdesk/dataproviders/oracle/PMTransactionDataProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package it.pagopa.ecommerce.helpdesk.dataproviders.oracle | ||
|
||
import io.r2dbc.spi.ConnectionFactory | ||
import it.pagopa.ecommerce.helpdesk.dataproviders.TransactionDataProvider | ||
import it.pagopa.generated.ecommerce.helpdesk.model.* | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.stereotype.Component | ||
import reactor.core.publisher.Mono | ||
|
||
@Component | ||
class PMTransactionDataProvider(@Autowired connectionFactory: ConnectionFactory) : | ||
TransactionDataProvider { | ||
|
||
override fun totalRecorcCount(searchCriteria: HelpDeskSearchTransactionRequestDto): Mono<Int> = | ||
when (searchCriteria) { | ||
is SearchTransactionRequestPaymentTokenDto -> Mono.just(0) | ||
is SearchTransactionRequestRptIdDto -> Mono.just(0) | ||
is SearchTransactionRequestTransactionIdDto -> Mono.just(0) | ||
is SearchTransactionRequestEmailDto -> Mono.just(0) // TODO implementare | ||
is SearchTransactionRequestFiscalCodeDto -> Mono.just(0) // TODO implementare | ||
else -> | ||
Mono.error( | ||
RuntimeException("Unhandled search criteria ${searchCriteria.javaClass}") | ||
) | ||
} | ||
|
||
override fun findResult( | ||
searchCriteria: HelpDeskSearchTransactionRequestDto, | ||
offset: Int, | ||
limit: Int | ||
): Mono<List<TransactionResultDto>> = | ||
when (searchCriteria) { | ||
is SearchTransactionRequestPaymentTokenDto -> Mono.just(listOf(TransactionResultDto())) | ||
is SearchTransactionRequestRptIdDto -> Mono.just(listOf(TransactionResultDto())) | ||
is SearchTransactionRequestTransactionIdDto -> Mono.just(listOf(TransactionResultDto())) | ||
is SearchTransactionRequestEmailDto -> | ||
Mono.just(listOf(TransactionResultDto())) // TODO implementare | ||
is SearchTransactionRequestFiscalCodeDto -> | ||
Mono.just(listOf(TransactionResultDto())) // TODO implementare | ||
else -> | ||
Mono.error( | ||
RuntimeException("Unhandled search criteria ${searchCriteria.javaClass}") | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<springProperty name="ECS_SERVICE_VERSION" source="build.version"/> | ||
<appender name="ECS_JSON_CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder class="co.elastic.logging.logback.EcsEncoder"> | ||
<serviceName>${ECS_SERVICE_NAME:-undefined}</serviceName> | ||
<serviceVersion>${ECS_SERVICE_VERSION}</serviceVersion> | ||
<serviceEnvironment>${ECS_SERVICE_ENVIRONMENT:-undefined}</serviceEnvironment> | ||
</encoder> | ||
</appender> | ||
<root level="INFO"> | ||
<appender-ref ref="ECS_JSON_CONSOLE"/> | ||
</root> | ||
</configuration> |