Поправил seek пагинацию
This commit is contained in:
parent
3869a4f418
commit
2b5d5ce9f6
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>dev.struchkov.haiti.filter</groupId>
|
||||
<artifactId>haiti-filter-jooq</artifactId>
|
||||
<version>0.7.0</version>
|
||||
<version>0.8.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Haiti Filter JOOQ</name>
|
||||
|
@ -189,7 +189,9 @@ public class CriteriaJooqFilter {
|
||||
|
||||
private SelectLimitStep<? extends Record> getOrderBy(SelectHavingStep<? extends Record> groupBy) {
|
||||
if (!sorts.isEmpty()) {
|
||||
return groupBy.orderBy(getOrderBy());
|
||||
final SelectSeekStepN<? extends Record> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user