Поправил ошибку при использовании сортировки

This commit is contained in:
Struchkov Mark 2022-02-18 17:12:58 +03:00
parent 073372a51c
commit a16aff6bfd

View File

@ -14,6 +14,7 @@ import org.jooq.DSLContext;
import org.jooq.Query;
import org.jooq.conf.ParamType;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
@ -29,6 +30,7 @@ public class QuarkusFilter<ID> {
private final PgPool pgPool;
private final CriteriaJooqFilter jooqFilter;
private PageableOffset offset;
private final List<String> sortFieldNames = new ArrayList<>();
private QuarkusFilter(PgPool pgPool, String table, DSLContext dslContext) {
dslContext.settings().withParamType(ParamType.NAMED_OR_INLINED);
@ -79,17 +81,26 @@ public class QuarkusFilter<ID> {
}
public QuarkusFilter<ID> sort(SortContainer container) {
jooqFilter.sort(container);
if (container != null && container.getFieldName() != null) {
jooqFilter.sort(container);
sortFieldNames.add(container.getFieldName());
}
return this;
}
public QuarkusFilter<ID> sort(String field, SortType sortType) {
jooqFilter.sort(field, sortType);
if (field != null) {
jooqFilter.sort(field, sortType);
sortFieldNames.add(field);
}
return this;
}
public QuarkusFilter<ID> sort(String field) {
jooqFilter.sort(field);
if (field != null) {
jooqFilter.sort(field);
sortFieldNames.add(field);
}
return this;
}
@ -125,6 +136,7 @@ public class QuarkusFilter<ID> {
public Uni<FilterResult<ID>> filterResult(Class<ID> idType, String idField) {
jooqFilter.groupBy(idField);
jooqFilter.groupBy(sortFieldNames);
distinctCount = true;
final Uni<Long> count = count();
final Uni<List<ID>> content = build(idType, idField);