diff --git a/pom.xml b/pom.xml index 530905f..3e2f67d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.haiti.filter haiti-filter-jooq - 0.7.0 + 0.8.0 jar Haiti Filter JOOQ diff --git a/src/main/java/dev/struchkov/haiti/filter/jooq/CriteriaJooqFilter.java b/src/main/java/dev/struchkov/haiti/filter/jooq/CriteriaJooqFilter.java index 3e2d418..742f78b 100644 --- a/src/main/java/dev/struchkov/haiti/filter/jooq/CriteriaJooqFilter.java +++ b/src/main/java/dev/struchkov/haiti/filter/jooq/CriteriaJooqFilter.java @@ -189,7 +189,9 @@ public class CriteriaJooqFilter { private SelectLimitStep getOrderBy(SelectHavingStep groupBy) { if (!sorts.isEmpty()) { - return groupBy.orderBy(getOrderBy()); + final SelectSeekStepN sort = groupBy.orderBy(getOrderBy()); + setPaginationSeek(sort); + return sort; } return groupBy; } @@ -275,16 +277,14 @@ public class CriteriaJooqFilter { if (seek != null) { Inspector.isNotNull(() -> new FilterJooqHaitiException("При использовании пагинации типа seek необходимо указать сортировку"), sort); final Integer pageSize = seek.getPageSize(); - final Object lastId = seek.getLastId(); - if (pageSize != null) { - if (lastId != null) { - sort - .seek(lastId) - .limit(pageSize); - } else { - sort - .limit(pageSize); - } + final Object[] values = seek.getValues(); + if (values != null) { + sort + .seek(values) + .limit(pageSize); + } else { + sort + .limit(pageSize); } } } diff --git a/src/main/java/dev/struchkov/haiti/filter/jooq/page/PageableSeek.java b/src/main/java/dev/struchkov/haiti/filter/jooq/page/PageableSeek.java index 9922f74..258d0dd 100644 --- a/src/main/java/dev/struchkov/haiti/filter/jooq/page/PageableSeek.java +++ b/src/main/java/dev/struchkov/haiti/filter/jooq/page/PageableSeek.java @@ -2,17 +2,19 @@ package dev.struchkov.haiti.filter.jooq.page; import dev.struchkov.haiti.utils.Inspector; +import static dev.struchkov.haiti.filter.jooq.exception.FilterJooqHaitiException.filterJooqException; + public class PageableSeek { - private final Object lastId; + private final Object[] values; private int pageSize = 30; - private PageableSeek(Object lastId) { - this.lastId = lastId; + private PageableSeek(Object[] values) { + this.values = values; } - private PageableSeek(Object lastId, int pageSize) { - this.lastId = lastId; + private PageableSeek(Object[] values, int pageSize) { + this.values = values; this.pageSize = pageSize; } @@ -20,22 +22,22 @@ public class PageableSeek { return new PageableSeek(null); } - public static PageableSeek of(int pageSize) { + public static PageableSeek ofPageSize(int pageSize) { return new PageableSeek(null, pageSize); } - public static PageableSeek of(Object lastId) { - Inspector.isNotNull(lastId); - return new PageableSeek(lastId); + public static PageableSeek ofValues(Object... values) { + Inspector.isNotEmpty(filterJooqException("Переданы пустой набор данных для PageableSeek"), values); + return new PageableSeek(values); } - public static PageableSeek of(Object lastId, int pageSize) { - Inspector.isNotNull(lastId); - return new PageableSeek(lastId, pageSize); + public static PageableSeek ofPageSizeAndValues(int pageSize, Object... values) { + Inspector.isNotEmpty(filterJooqException("Переданы пустой набор данных для PageableSeek"), values); + return new PageableSeek(values, pageSize); } - public Object getLastId() { - return lastId; + public Object[] getValues() { + return values; } public int getPageSize() {