From 2b5d5ce9f6e262d5470770f9fe4bccccea083abf Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Wed, 7 Dec 2022 09:27:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20seek=20=D0=BF=D0=B0=D0=B3=D0=B8=D0=BD=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../haiti/filter/jooq/CriteriaJooqFilter.java | 22 +++++++------- .../haiti/filter/jooq/page/PageableSeek.java | 30 ++++++++++--------- 3 files changed, 28 insertions(+), 26 deletions(-) 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() {