This commit is contained in:
Struchkov Mark 2022-11-30 21:07:16 +03:00
parent 1b89feade7
commit 3869a4f418
6 changed files with 28 additions and 28 deletions

View File

@ -6,7 +6,7 @@
<groupId>dev.struchkov.haiti.filter</groupId>
<artifactId>haiti-filter-jooq</artifactId>
<version>0.6.0-SNAPSHOT</version>
<version>0.7.0</version>
<packaging>jar</packaging>
<name>Haiti Filter JOOQ</name>
@ -30,7 +30,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<jooq.version>3.15.6</jooq.version>
<jooq.version>3.15.5</jooq.version>
<plugin.nexus.staging.ver>1.6.8</plugin.nexus.staging.ver>
<plugin.maven.source.ver>3.2.1</plugin.maven.source.ver>
@ -43,7 +43,7 @@
<dependency>
<groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti-bom</artifactId>
<version>1.0.0</version>
<version>1.4.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@ -7,7 +7,7 @@ import dev.struchkov.haiti.filter.jooq.page.PageableOffset;
import dev.struchkov.haiti.filter.jooq.page.PageableSeek;
import dev.struchkov.haiti.filter.jooq.sort.SortContainer;
import dev.struchkov.haiti.filter.jooq.sort.SortType;
import dev.struchkov.haiti.utils.Assert;
import dev.struchkov.haiti.utils.Inspector;
import org.jooq.Condition;
import org.jooq.DSLContext;
import org.jooq.Field;
@ -97,15 +97,15 @@ public class CriteriaJooqFilter {
// }
public CriteriaJooqFilter page(PageableOffset offset) {
Assert.isNotNull(offset);
Assert.isNull(seek, filterJooqException("Нельзя установить два типа пагинации одновременно"));
Inspector.isNotNull(offset);
Inspector.isNull(seek, filterJooqException("Нельзя установить два типа пагинации одновременно"));
this.offset = offset;
return this;
}
public CriteriaJooqFilter page(PageableSeek seek) {
Assert.isNotNull(seek);
Assert.isNull(offset, filterJooqException("Нельзя установить два типа пагинации одновременно"));
Inspector.isNotNull(seek);
Inspector.isNull(offset, filterJooqException("Нельзя установить два типа пагинации одновременно"));
this.seek = seek;
return this;
}
@ -153,7 +153,7 @@ public class CriteriaJooqFilter {
}
public CriteriaJooqFilter join(JoinTable... joinTables) {
Assert.isNotNull(joinTables);
Inspector.isNotNull(joinTables);
this.joinTables.addAll(Arrays.stream(joinTables).collect(Collectors.toList()));
return this;
}
@ -273,7 +273,7 @@ public class CriteriaJooqFilter {
private void setPaginationSeek(SelectSeekStepN<? extends Record> sort) {
if (seek != null) {
Assert.isNotNull(sort, () -> new FilterJooqHaitiException("При использовании пагинации типа seek необходимо указать сортировку"));
Inspector.isNotNull(() -> new FilterJooqHaitiException("При использовании пагинации типа seek необходимо указать сортировку"), sort);
final Integer pageSize = seek.getPageSize();
final Object lastId = seek.getLastId();
if (pageSize != null) {

View File

@ -1,6 +1,6 @@
package dev.struchkov.haiti.filter.jooq;
import dev.struchkov.haiti.utils.Assert;
import dev.struchkov.haiti.utils.Inspector;
import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.impl.DSL;
@ -26,7 +26,7 @@ public class CriteriaJooqQuery {
}
public <Y extends Comparable<? super Y>> CriteriaJooqQuery between(String field, Y from, Y to) {
Assert.isNotNull(field);
Inspector.isNotNull(field);
if (from != null && to != null) {
Condition condition = DSL.field(field).between(from, to);
conditions.add(condition);
@ -35,7 +35,7 @@ public class CriteriaJooqQuery {
}
public CriteriaJooqQuery matchPhrase(String field, Object value) {
Assert.isNotNull(field);
Inspector.isNotNull(field);
if (value != null) {
final Condition condition = condition(Map.of(field(field), value));
conditions.add(condition);
@ -44,7 +44,7 @@ public class CriteriaJooqQuery {
}
public <U> CriteriaJooqQuery matchPhrase(String field, Set<U> values) {
Assert.isNotNull(field);
Inspector.isNotNull(field);
if (values != null) {
if (values.isEmpty()) {
conditions.add(DSL.field(field).isNull());
@ -73,7 +73,7 @@ public class CriteriaJooqQuery {
}
public CriteriaJooqQuery like(String field, String value, boolean ignoreCase) {
Assert.isNotNull(field);
Inspector.isNotNull(field);
final Field<Object> query = field(field);
if (value != null) {
if (ignoreCase) {

View File

@ -1,6 +1,6 @@
package dev.struchkov.haiti.filter.jooq.join;
import dev.struchkov.haiti.utils.Assert;
import dev.struchkov.haiti.utils.Inspector;
/**
* Контейнер для соединения с таблицами.
@ -24,32 +24,32 @@ public class JoinTable {
}
public static JoinTable ofLeft(String tableName, String fieldBase, String fieldReference) {
Assert.isNotNull(tableName, fieldBase, fieldReference);
Inspector.isNotNull(tableName, fieldBase, fieldReference);
return new JoinTable(tableName, fieldBase, fieldReference, JoinTypeOperation.LEFT, null);
}
public static JoinTable ofLeft(String tableName, String fieldBase, String fieldReference, String alias) {
Assert.isNotNull(tableName, fieldBase, fieldReference, alias);
Inspector.isNotNull(tableName, fieldBase, fieldReference, alias);
return new JoinTable(tableName, fieldBase, fieldReference, JoinTypeOperation.LEFT, alias);
}
public static JoinTable onRight(String tableName, String fieldBase, String fieldReference) {
Assert.isNotNull(tableName, fieldBase, fieldReference);
Inspector.isNotNull(tableName, fieldBase, fieldReference);
return new JoinTable(tableName, fieldBase, fieldReference, JoinTypeOperation.RIGHT, null);
}
public static JoinTable onRight(String tableName, String fieldBase, String fieldReference, String alias) {
Assert.isNotNull(tableName, fieldBase, fieldReference, alias);
Inspector.isNotNull(tableName, fieldBase, fieldReference, alias);
return new JoinTable(tableName, fieldBase, fieldReference, JoinTypeOperation.RIGHT, alias);
}
public static JoinTable of(String tableName, String fieldBase, String fieldReference, JoinTypeOperation joinType) {
Assert.isNotNull(tableName, fieldBase, fieldReference);
Inspector.isNotNull(tableName, fieldBase, fieldReference);
return new JoinTable(tableName, fieldBase, fieldReference, joinType, null);
}
public static JoinTable of(String tableName, String fieldBase, String fieldReference, JoinTypeOperation joinType, String alias) {
Assert.isNotNull(tableName, fieldBase, fieldReference, alias);
Inspector.isNotNull(tableName, fieldBase, fieldReference, alias);
return new JoinTable(tableName, fieldBase, fieldReference, joinType, alias);
}

View File

@ -1,6 +1,6 @@
package dev.struchkov.haiti.filter.jooq.page;
import dev.struchkov.haiti.utils.Assert;
import dev.struchkov.haiti.utils.Inspector;
public class PageableSeek {
@ -25,12 +25,12 @@ public class PageableSeek {
}
public static PageableSeek of(Object lastId) {
Assert.isNotNull(lastId);
Inspector.isNotNull(lastId);
return new PageableSeek(lastId);
}
public static PageableSeek of(Object lastId, int pageSize) {
Assert.isNotNull(lastId);
Inspector.isNotNull(lastId);
return new PageableSeek(lastId, pageSize);
}

View File

@ -1,7 +1,7 @@
package dev.struchkov.haiti.filter.jooq.sort;
import dev.struchkov.haiti.utils.Assert;
import dev.struchkov.haiti.utils.Inspector;
public class SortContainer {
@ -18,12 +18,12 @@ public class SortContainer {
}
public static SortContainer of(String fieldName) {
Assert.isNotNull(fieldName);
Inspector.isNotNull(fieldName);
return new SortContainer(fieldName);
}
public static SortContainer of(String fieldName, SortType sortType) {
Assert.isNotNull(fieldName);
Inspector.isNotNull(fieldName);
return new SortContainer(fieldName, sortType == null ? SortType.ASC : sortType);
}