generated from pagopa/template-java-spring-microservice
-
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.
Merge pull request #26 from pagopa/PPANTT-54-feat-introduced-page-info
[PPANTT-54] feat: introducing total counter to pageInfo on apis
- Loading branch information
Showing
12 changed files
with
1,679 additions
and
1,793 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/main/java/it/pagopa/selfcare/pagopa/entities/BrokerInstitutionAggregate.java
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,18 @@ | ||
package it.pagopa.selfcare.pagopa.entities; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class BrokerInstitutionAggregate { | ||
|
||
private List<BrokerInstitutionEntity> institutionEntities; | ||
private Long total; | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/it/pagopa/selfcare/pagopa/entities/IbanAggregate.java
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,19 @@ | ||
package it.pagopa.selfcare.pagopa.entities; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class IbanAggregate { | ||
|
||
private List<IbanEntity> ibansSlice; | ||
private Long total; | ||
|
||
} |
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
12 changes: 9 additions & 3 deletions
12
src/main/java/it/pagopa/selfcare/pagopa/repository/BrokerIbansRepository.java
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 |
---|---|---|
@@ -1,16 +1,22 @@ | ||
package it.pagopa.selfcare.pagopa.repository; | ||
|
||
import it.pagopa.selfcare.pagopa.entities.BrokerIbansEntity; | ||
import it.pagopa.selfcare.pagopa.entities.IbanAggregate; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.mongodb.repository.Aggregation; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
import org.springframework.data.mongodb.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
|
||
@Repository | ||
public interface BrokerIbansRepository extends MongoRepository<BrokerIbansEntity, String> { | ||
|
||
@Query(value = "{ brokerCode : ?0 }", fields = "{ ibans: { $slice: [?1, ?2]}}") | ||
Optional<BrokerIbansEntity> getBrokerIbans(String brokerCode, Integer skip, Integer limit); | ||
@Aggregation(pipeline = { | ||
"{ $match : { brokerCode : ?0 } }", | ||
"{ $project: { ibansSlice : { $slice: ['$ibans', ?1, ?2] }, total: { $size: '$ibans' }, } }" | ||
}) | ||
Optional<IbanAggregate> getBrokerIbans(String brokerCode, Integer sliceStart, Integer size); | ||
|
||
} |
11 changes: 8 additions & 3 deletions
11
src/main/java/it/pagopa/selfcare/pagopa/repository/BrokerInstitutionsRepository.java
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 |
---|---|---|
@@ -1,16 +1,21 @@ | ||
package it.pagopa.selfcare.pagopa.repository; | ||
|
||
import it.pagopa.selfcare.pagopa.entities.BrokerInstitutionAggregate; | ||
import it.pagopa.selfcare.pagopa.entities.BrokerInstitutionsEntity; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.mongodb.repository.Aggregation; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
import org.springframework.data.mongodb.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface BrokerInstitutionsRepository extends MongoRepository<BrokerInstitutionsEntity, String> { | ||
|
||
@Query(value = "{ brokerCode : ?0 }", fields = "{ institutions: { $slice: [?1, ?2]}}") | ||
Optional<BrokerInstitutionsEntity> findPagedInstitutionsByBrokerCode(String brokerCode, int skip, Integer limit); | ||
@Aggregation(pipeline = { | ||
"{ $match : { brokerCode : ?0 } }", | ||
"{ $project: { institutionsSlice : { $slice: ['$institutions', ?1, ?2] }, total: { $size: '$institutions' }, } }" | ||
}) | ||
Optional<BrokerInstitutionAggregate> findPagedInstitutionsByBrokerCode(String brokerCode, Integer sliceStart, Integer size); | ||
|
||
} |
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
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