|
29 | 29 | import org.socialsignin.spring.data.dynamodb.marshaller.Instant2IsoDynamoDBMarshaller;
|
30 | 30 | import org.socialsignin.spring.data.dynamodb.query.Query;
|
31 | 31 | import org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBEntityInformation;
|
| 32 | +import org.springframework.data.domain.Pageable; |
32 | 33 | import org.springframework.data.domain.Sort;
|
33 | 34 | import org.springframework.data.domain.Sort.Direction;
|
34 | 35 | import org.springframework.data.domain.Sort.Order;
|
@@ -66,6 +67,7 @@ public abstract class AbstractDynamoDBQueryCriteria<T, ID> implements DynamoDBQu
|
66 | 67 | protected Object hashKeyPropertyValue;
|
67 | 68 | protected String globalSecondaryIndexName;
|
68 | 69 | protected Sort sort;
|
| 70 | + protected Pageable pageable; |
69 | 71 |
|
70 | 72 | public abstract boolean isApplicableForLoad();
|
71 | 73 |
|
@@ -132,9 +134,16 @@ protected QueryRequest buildQueryRequest(String tableName, String theIndexName,
|
132 | 134 | queryRequest.setSelect(Select.ALL_PROJECTED_ATTRIBUTES);
|
133 | 135 | applySortIfSpecified(queryRequest, new ArrayList<String>(new HashSet<String>(allowedSortProperties)));
|
134 | 136 | }
|
| 137 | + applyPageableIfSpecified(queryRequest); |
135 | 138 | return queryRequest;
|
136 | 139 | }
|
137 | 140 |
|
| 141 | + private void applyPageableIfSpecified(QueryRequest queryRequest) { |
| 142 | + if (pageable != Pageable.unpaged()) { |
| 143 | + queryRequest.setLimit(pageable.getPageSize()); |
| 144 | + } |
| 145 | + } |
| 146 | + |
138 | 147 | protected void applySortIfSpecified(DynamoDBQueryExpression<T> queryExpression, List<String> permittedPropertyNames) {
|
139 | 148 | if (permittedPropertyNames.size() > 1) {
|
140 | 149 | throw new UnsupportedOperationException("Can only sort by at most a single range or index range key");
|
@@ -688,4 +697,10 @@ public DynamoDBQueryCriteria<T, ID> withSort(Sort sort) {
|
688 | 697 | return this;
|
689 | 698 | }
|
690 | 699 |
|
| 700 | + @Override |
| 701 | + public DynamoDBQueryCriteria<T, ID> withPageable(Pageable pageable) { |
| 702 | + this.pageable = pageable; |
| 703 | + return this; |
| 704 | + } |
| 705 | + |
691 | 706 | }
|
0 commit comments