refactor(all): 调整模块依赖,划分代码范围
This commit is contained in:
61
pom.xml
61
pom.xml
@@ -11,9 +11,10 @@
|
||||
|
||||
<modules>
|
||||
<module>spring-boot-service-template-common</module>
|
||||
<module>spring-boot-service-template-eq</module>
|
||||
<module>spring-boot-service-template-jpa</module>
|
||||
<module>spring-boot-service-template-xbatis</module>
|
||||
<module>spring-boot-service-template-database/spring-boot-service-template-database-common</module>
|
||||
<module>spring-boot-service-template-database/spring-boot-service-template-database-eq</module>
|
||||
<module>spring-boot-service-template-database/spring-boot-service-template-database-jpa</module>
|
||||
<module>spring-boot-service-template-database/spring-boot-service-template-database-xbatis</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
@@ -29,6 +30,7 @@
|
||||
<mapstruct.version>1.6.3</mapstruct.version>
|
||||
<mapstruct-plus.version>1.5.0</mapstruct-plus.version>
|
||||
<datasource-decorator.version>2.0.0</datasource-decorator.version>
|
||||
<easy-query.version>3.1.68</easy-query.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -36,6 +38,10 @@
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jspecify</groupId>
|
||||
<artifactId>jspecify</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -47,7 +53,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.lanyuanxiaoyao</groupId>
|
||||
<artifactId>spring-boot-service-template-jpa</artifactId>
|
||||
<artifactId>spring-boot-service-template-database-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -67,23 +73,6 @@
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.blinkfox</groupId>
|
||||
<artifactId>fenix-spring-boot-starter</artifactId>
|
||||
<version>${fenix.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign.querydsl</groupId>
|
||||
<artifactId>querydsl-jpa</artifactId>
|
||||
<version>${querydsl.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate.orm</groupId>
|
||||
<artifactId>hibernate-ant</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
@@ -102,10 +91,21 @@
|
||||
<version>${datasource-decorator.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- jpa -->
|
||||
<dependency>
|
||||
<groupId>org.jspecify</groupId>
|
||||
<artifactId>jspecify</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<groupId>com.blinkfox</groupId>
|
||||
<artifactId>fenix-spring-boot-starter</artifactId>
|
||||
<version>${fenix.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign.querydsl</groupId>
|
||||
<artifactId>querydsl-jpa</artifactId>
|
||||
<version>${querydsl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.orm</groupId>
|
||||
<artifactId>hibernate-ant</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- xbatis -->
|
||||
@@ -116,6 +116,19 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- easy-query -->
|
||||
<dependency>
|
||||
<groupId>com.easy-query</groupId>
|
||||
<artifactId>sql-springboot4-starter</artifactId>
|
||||
<version>3.1.68</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jspecify</groupId>
|
||||
<artifactId>jspecify</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.service;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.ObjectHelper;
|
||||
|
||||
public abstract class QueryParser<O> {
|
||||
protected abstract void nullEqual(Query.Queryable queryable);
|
||||
|
||||
protected abstract void notNullEqual(Query.Queryable queryable);
|
||||
|
||||
protected abstract void empty(Query.Queryable queryable);
|
||||
|
||||
protected abstract void notEmpty(Query.Queryable queryable);
|
||||
|
||||
protected abstract void equal(Query.Queryable queryable);
|
||||
|
||||
protected abstract void notEqual(Query.Queryable queryable);
|
||||
|
||||
protected abstract void like(Query.Queryable queryable);
|
||||
|
||||
protected abstract void notLike(Query.Queryable queryable);
|
||||
|
||||
protected abstract void contain(Query.Queryable queryable);
|
||||
|
||||
protected abstract void notContain(Query.Queryable queryable);
|
||||
|
||||
protected abstract void startWith(Query.Queryable queryable);
|
||||
|
||||
protected abstract void notStartWith(Query.Queryable queryable);
|
||||
|
||||
protected abstract void endWith(Query.Queryable queryable);
|
||||
|
||||
protected abstract void notEndWith(Query.Queryable queryable);
|
||||
|
||||
protected abstract void great(Query.Queryable queryable);
|
||||
|
||||
protected abstract void less(Query.Queryable queryable);
|
||||
|
||||
protected abstract void greatEqual(Query.Queryable queryable);
|
||||
|
||||
protected abstract void lessEqual(Query.Queryable queryable);
|
||||
|
||||
protected abstract void inside(Query.Queryable queryable);
|
||||
|
||||
protected abstract void notInside(Query.Queryable queryable);
|
||||
|
||||
protected abstract void between(Query.Queryable queryable);
|
||||
|
||||
protected abstract void notBetween(Query.Queryable queryable);
|
||||
|
||||
protected abstract O build();
|
||||
|
||||
public O build(Query.Queryable queryable) {
|
||||
if (ObjectHelper.isNull(queryable)) {
|
||||
return null;
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.nullEqual())) {
|
||||
nullEqual(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notNullEqual())) {
|
||||
notNullEqual(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.empty())) {
|
||||
empty(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notEmpty())) {
|
||||
notEmpty(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.equal())) {
|
||||
equal(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notEqual())) {
|
||||
notEqual(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.like())) {
|
||||
like(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notLike())) {
|
||||
notLike(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.contain())) {
|
||||
contain(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notContain())) {
|
||||
notContain(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.startWith())) {
|
||||
startWith(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notStartWith())) {
|
||||
notStartWith(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.endWith())) {
|
||||
endWith(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notEndWith())) {
|
||||
notEndWith(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.great())) {
|
||||
great(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.less())) {
|
||||
less(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.greatEqual())) {
|
||||
greatEqual(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.lessEqual())) {
|
||||
lessEqual(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.inside())) {
|
||||
inside(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notInside())) {
|
||||
notInside(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.between())) {
|
||||
between(queryable);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notBetween())) {
|
||||
notBetween(queryable);
|
||||
}
|
||||
return build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.lanyuanxiaoyao</groupId>
|
||||
<artifactId>spring-boot-service-template</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-boot-service-template-database-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.lanyuanxiaoyao</groupId>
|
||||
<artifactId>spring-boot-service-template-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.gavlyukovskiy</groupId>
|
||||
<artifactId>p6spy-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.controller;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.controller;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.GlobalResponse;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.GlobalResponse;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Query;
|
||||
|
||||
/**
|
||||
* 查询控制器接口,用于定义统一的查询实体详情和列表的接口规范
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.controller;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.controller;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.GlobalResponse;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.GlobalResponse;
|
||||
|
||||
/**
|
||||
* 删除控制器接口,用于定义统一的删除实体对象的接口规范
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.controller;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.controller;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.GlobalResponse;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.GlobalResponse;
|
||||
|
||||
/**
|
||||
* 保存控制器接口,用于定义统一的保存实体对象的接口规范
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.controller;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.controller;
|
||||
|
||||
public interface SimpleController<SAVE_ITEM, LIST_ITEM, DETAIL_ITEM> extends SaveController<SAVE_ITEM>, QueryController<LIST_ITEM, DETAIL_ITEM>, RemoveController {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.entity;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.entity;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.entity;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.exception;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.exception;
|
||||
|
||||
public class IdNotFoundException extends RuntimeException {
|
||||
public IdNotFoundException(Long id) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.exception;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.exception;
|
||||
|
||||
public class NotCollectionException extends RuntimeException {
|
||||
public NotCollectionException(String variable) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.exception;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.exception;
|
||||
|
||||
public class NotComparableException extends RuntimeException {
|
||||
public NotComparableException(String variable) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.exception;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.exception;
|
||||
|
||||
public class NotStringException extends RuntimeException {
|
||||
public NotStringException(String variable) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.helper;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.helper;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.lanyuanxiaoyao.service.template.database.common.service;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.ObjectHelper;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Query;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
public abstract class QueryParser<O> {
|
||||
private final Query.Queryable queryable;
|
||||
private final O container;
|
||||
|
||||
protected abstract void nullEqual(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void notNullEqual(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void empty(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void notEmpty(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void equal(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void notEqual(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void like(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void notLike(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void contain(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void notContain(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void startWith(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void notStartWith(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void endWith(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void notEndWith(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void great(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void less(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void greatEqual(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void lessEqual(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void inside(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void notInside(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void between(Query.Queryable queryable, O container);
|
||||
|
||||
protected abstract void notBetween(Query.Queryable queryable, O container);
|
||||
|
||||
public void build() {
|
||||
if (ObjectHelper.isNull(queryable)) {
|
||||
return;
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.nullEqual())) {
|
||||
nullEqual(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notNullEqual())) {
|
||||
notNullEqual(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.empty())) {
|
||||
empty(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notEmpty())) {
|
||||
notEmpty(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.equal())) {
|
||||
equal(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notEqual())) {
|
||||
notEqual(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.like())) {
|
||||
like(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notLike())) {
|
||||
notLike(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.contain())) {
|
||||
contain(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notContain())) {
|
||||
notContain(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.startWith())) {
|
||||
startWith(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notStartWith())) {
|
||||
notStartWith(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.endWith())) {
|
||||
endWith(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notEndWith())) {
|
||||
notEndWith(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.great())) {
|
||||
great(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.less())) {
|
||||
less(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.greatEqual())) {
|
||||
greatEqual(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.lessEqual())) {
|
||||
lessEqual(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.inside())) {
|
||||
inside(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notInside())) {
|
||||
notInside(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.between())) {
|
||||
between(queryable, container);
|
||||
}
|
||||
if (ObjectHelper.isNotEmpty(queryable.notBetween())) {
|
||||
notBetween(queryable, container);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.service;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.service;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Page;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Page;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Query;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.service;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.service;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.service;
|
||||
|
||||
/**
|
||||
* 保存服务接口,用于定义统一的保存实体对象的服务规范
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.common.service;
|
||||
package com.lanyuanxiaoyao.service.template.database.common.service;
|
||||
|
||||
public interface SimpleService<ENTITY> extends SaveService<ENTITY>, QueryService<ENTITY>, RemoveService<ENTITY> {
|
||||
}
|
||||
@@ -9,32 +9,23 @@
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-boot-service-template-eq</artifactId>
|
||||
<artifactId>spring-boot-service-template-database-eq</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.lanyuanxiaoyao</groupId>
|
||||
<artifactId>spring-boot-service-template-common</artifactId>
|
||||
<artifactId>spring-boot-service-template-database-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.easy-query</groupId>
|
||||
<artifactId>sql-springboot4-starter</artifactId>
|
||||
<version>3.1.68</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.gavlyukovskiy</groupId>
|
||||
<artifactId>p6spy-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jspecify</groupId>
|
||||
<artifactId>jspecify</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -70,7 +61,7 @@
|
||||
<path>
|
||||
<groupId>com.easy-query</groupId>
|
||||
<artifactId>sql-processor</artifactId>
|
||||
<version>3.1.68</version>
|
||||
<version>${easy-query.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
@@ -2,10 +2,10 @@ package com.lanyuanxiaoyao.service.template.eq.controller;
|
||||
|
||||
import com.easy.query.core.proxy.AbstractProxyEntity;
|
||||
import com.easy.query.core.proxy.ProxyEntityAvailable;
|
||||
import com.lanyuanxiaoyao.service.template.common.controller.SimpleController;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.GlobalResponse;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.ObjectHelper;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.controller.SimpleController;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.GlobalResponse;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.eq.entity.SimpleEntity;
|
||||
import com.lanyuanxiaoyao.service.template.eq.service.SimpleServiceSupport;
|
||||
import java.util.function.Function;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.lanyuanxiaoyao.service.template.eq.entity;
|
||||
|
||||
import com.easy.query.core.basic.extension.generated.PrimaryKeyGenerator;
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.SnowflakeHelper;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.helper.SnowflakeHelper;
|
||||
import java.io.Serializable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -4,12 +4,12 @@ import com.easy.query.api.proxy.client.EasyEntityQuery;
|
||||
import com.easy.query.core.enums.SQLExecuteStrategyEnum;
|
||||
import com.easy.query.core.proxy.AbstractProxyEntity;
|
||||
import com.easy.query.core.proxy.ProxyEntityAvailable;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Page;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.common.exception.IdNotFoundException;
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.ObjectHelper;
|
||||
import com.lanyuanxiaoyao.service.template.common.service.QueryParser;
|
||||
import com.lanyuanxiaoyao.service.template.common.service.SimpleService;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Page;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.exception.IdNotFoundException;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.service.QueryParser;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.service.SimpleService;
|
||||
import com.lanyuanxiaoyao.service.template.eq.entity.SimpleEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -17,6 +17,8 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mapstruct.Named;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@@ -27,6 +29,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity & ProxyEn
|
||||
protected final EasyEntityQuery entityQuery;
|
||||
private final Class<ENTITY> target;
|
||||
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public Long save(ENTITY entity) {
|
||||
if (ObjectHelper.isNull(entity.getId())) {
|
||||
@@ -39,6 +42,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity & ProxyEn
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public void save(Iterable<ENTITY> entities) {
|
||||
var insertList = new ArrayList<ENTITY>();
|
||||
@@ -94,7 +98,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity & ProxyEn
|
||||
|
||||
var result = entityQuery.queryable(target)
|
||||
.where(this::commonPredicates)
|
||||
.where(proxy -> new EqQueryParser<ENTITY, PROXY>(proxy).build(query.query()))
|
||||
.where(proxy -> new EqQueryParser<ENTITY, PROXY>(query.query(), proxy).build())
|
||||
.orderBy(ObjectHelper.isNotEmpty(query.sort()), proxy -> query.sort().forEach(sort -> proxy.anyColumn(sort.column()).orderBy(Query.Sortable.Direction.ASC.equals(sort.direction()))))
|
||||
.toPageResult(index, size);
|
||||
|
||||
@@ -110,16 +114,19 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity & ProxyEn
|
||||
.singleOptional();
|
||||
}
|
||||
|
||||
@Named("detail")
|
||||
@Override
|
||||
public ENTITY detail(Long id) {
|
||||
return detailOptional(id).orElse(null);
|
||||
}
|
||||
|
||||
@Named("detailOrThrow")
|
||||
@Override
|
||||
public ENTITY detailOrThrow(Long id) {
|
||||
return detailOptional(id).orElseThrow(() -> new IdNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public void remove(Long id) {
|
||||
if (ObjectHelper.isNotNull(id)) {
|
||||
@@ -130,6 +137,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity & ProxyEn
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public void remove(Set<Long> ids) {
|
||||
if (ObjectHelper.isNotEmpty(ids)) {
|
||||
@@ -140,102 +148,103 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity & ProxyEn
|
||||
}
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
private static final class EqQueryParser<ENTITY extends SimpleEntity & ProxyEntityAvailable<ENTITY, PROXY>, PROXY extends AbstractProxyEntity<PROXY, ENTITY>> extends QueryParser<Void> {
|
||||
private final PROXY proxy;
|
||||
private static final class EqQueryParser<ENTITY extends SimpleEntity & ProxyEntityAvailable<ENTITY, PROXY>, PROXY extends AbstractProxyEntity<PROXY, ENTITY>> extends QueryParser<PROXY> {
|
||||
public EqQueryParser(Query.Queryable queryable, PROXY container) {
|
||||
super(queryable, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void nullEqual(Query.Queryable queryable) {
|
||||
protected void nullEqual(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.nullEqual().forEach(column -> proxy.anyColumn(column).isNull());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notNullEqual(Query.Queryable queryable) {
|
||||
protected void notNullEqual(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.notNullEqual().forEach(column -> proxy.anyColumn(column).isNotNull());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void empty(Query.Queryable queryable) {
|
||||
protected void empty(Query.Queryable queryable, PROXY proxy) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notEmpty(Query.Queryable queryable) {
|
||||
protected void notEmpty(Query.Queryable queryable, PROXY proxy) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void equal(Query.Queryable queryable) {
|
||||
protected void equal(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.equal().forEach((column, value) -> proxy.anyColumn(column).eq(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notEqual(Query.Queryable queryable) {
|
||||
protected void notEqual(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.notEqual().forEach((column, value) -> proxy.anyColumn(column).ne(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void like(Query.Queryable queryable) {
|
||||
protected void like(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.like().forEach((column, value) -> proxy.anyColumn(column).likeRaw(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notLike(Query.Queryable queryable) {
|
||||
protected void notLike(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.notLike().forEach((column, value) -> proxy.anyColumn(column).notLikeRaw(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void contain(Query.Queryable queryable) {
|
||||
protected void contain(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.contain().forEach((column, value) -> proxy.anyColumn(column).like(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notContain(Query.Queryable queryable) {
|
||||
protected void notContain(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.notContain().forEach((column, value) -> proxy.anyColumn(column).notLike(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startWith(Query.Queryable queryable) {
|
||||
protected void startWith(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.startWith().forEach((column, value) -> proxy.anyColumn(column).likeMatchLeft(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notStartWith(Query.Queryable queryable) {
|
||||
protected void notStartWith(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.notStartWith().forEach((column, value) -> proxy.anyColumn(column).notLikeMatchLeft(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endWith(Query.Queryable queryable) {
|
||||
protected void endWith(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.endWith().forEach((column, value) -> proxy.anyColumn(column).likeMatchRight(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notEndWith(Query.Queryable queryable) {
|
||||
protected void notEndWith(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.notEndWith().forEach((column, value) -> proxy.anyColumn(column).notLikeMatchRight(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void great(Query.Queryable queryable) {
|
||||
protected void great(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.great().forEach((column, value) -> proxy.anyColumn(column).gt(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void less(Query.Queryable queryable) {
|
||||
protected void less(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.less().forEach((column, value) -> proxy.anyColumn(column).lt(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void greatEqual(Query.Queryable queryable) {
|
||||
protected void greatEqual(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.greatEqual().forEach((column, value) -> proxy.anyColumn(column).ge(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void lessEqual(Query.Queryable queryable) {
|
||||
protected void lessEqual(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.lessEqual().forEach((column, value) -> proxy.anyColumn(column).le(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inside(Query.Queryable queryable) {
|
||||
protected void inside(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.inside()
|
||||
.entrySet()
|
||||
.stream()
|
||||
@@ -244,7 +253,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity & ProxyEn
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notInside(Query.Queryable queryable) {
|
||||
protected void notInside(Query.Queryable queryable, PROXY proxy) {
|
||||
queryable.notInside()
|
||||
.entrySet()
|
||||
.stream()
|
||||
@@ -253,18 +262,13 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity & ProxyEn
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void between(Query.Queryable queryable) {
|
||||
protected void between(Query.Queryable queryable, PROXY proxy) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notBetween(Query.Queryable queryable) {
|
||||
protected void notBetween(Query.Queryable queryable, PROXY proxy) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void build() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ spring:
|
||||
application:
|
||||
name: Test
|
||||
datasource:
|
||||
url: "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=MySQL;DATABASE_TO_LOWER=TRUE;INIT=runscript from '/Users/lanyuanxiaoyao/Project/IdeaProjects/spring-boot-service-template/spring-boot-service-template-eq/src/test/initial.sql'"
|
||||
url: "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=MySQL;DATABASE_TO_LOWER=TRUE;INIT=runscript from '/Users/lanyuanxiaoyao/Project/IdeaProjects/spring-boot-service-template/spring-boot-service-template-database/spring-boot-service-template-database-eq/src/test/initial.sql'"
|
||||
username: test
|
||||
password: test
|
||||
driver-class-name: org.h2.Driver
|
||||
@@ -9,12 +9,12 @@
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-boot-service-template-jpa</artifactId>
|
||||
<artifactId>spring-boot-service-template-database-jpa</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.lanyuanxiaoyao</groupId>
|
||||
<artifactId>spring-boot-service-template-common</artifactId>
|
||||
<artifactId>spring-boot-service-template-database-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -22,6 +22,7 @@
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
@@ -40,22 +41,6 @@
|
||||
<artifactId>hibernate-ant</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.gavlyukovskiy</groupId>
|
||||
<artifactId>p6spy-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jspecify</groupId>
|
||||
<artifactId>jspecify</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.lanyuanxiaoyao.service.template.jpa.controller;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.common.controller.SimpleController;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.GlobalResponse;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.ObjectHelper;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.controller.SimpleController;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.GlobalResponse;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.jpa.entity.SimpleEntity;
|
||||
import com.lanyuanxiaoyao.service.template.jpa.service.SimpleServiceSupport;
|
||||
import java.util.function.Function;
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.lanyuanxiaoyao.service.template.jpa.entity;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.SnowflakeHelper;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.helper.SnowflakeHelper;
|
||||
import java.io.Serializable;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.lanyuanxiaoyao.service.template.jpa.service;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Page;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.common.exception.IdNotFoundException;
|
||||
import com.lanyuanxiaoyao.service.template.common.exception.NotCollectionException;
|
||||
import com.lanyuanxiaoyao.service.template.common.exception.NotComparableException;
|
||||
import com.lanyuanxiaoyao.service.template.common.exception.NotStringException;
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.ObjectHelper;
|
||||
import com.lanyuanxiaoyao.service.template.common.service.QueryParser;
|
||||
import com.lanyuanxiaoyao.service.template.common.service.SimpleService;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Page;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.exception.IdNotFoundException;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.exception.NotCollectionException;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.exception.NotComparableException;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.exception.NotStringException;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.service.QueryParser;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.service.SimpleService;
|
||||
import com.lanyuanxiaoyao.service.template.jpa.entity.IdOnlyEntity;
|
||||
import com.lanyuanxiaoyao.service.template.jpa.entity.SimpleEntity;
|
||||
import com.lanyuanxiaoyao.service.template.jpa.repository.SimpleRepository;
|
||||
@@ -17,7 +17,6 @@ import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Path;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
@@ -29,6 +28,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.mapstruct.Named;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 简单服务支持类,提供基础的业务逻辑实现
|
||||
@@ -87,7 +87,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
* @param entity 需要保存的实体对象
|
||||
* @return 返回保存后的实体ID
|
||||
*/
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public Long save(ENTITY entity) {
|
||||
entity = repository.saveOrUpdateByNotNullProperties(entity);
|
||||
@@ -103,7 +103,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
*
|
||||
* @param entities 需要保存的实体对象集合
|
||||
*/
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public void save(Iterable<ENTITY> entities) {
|
||||
repository.saveOrUpdateAllByNotNullProperties(entities);
|
||||
@@ -194,7 +194,11 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
var result = repository.findAll(
|
||||
(root, query, builder) -> {
|
||||
var predicate = commonPredicates(root, query, builder);
|
||||
var queryPredicate = new JpaQueryParser<>(root, query, builder).build(listQuery.query());
|
||||
var predicates = new ArrayList<Predicate>();
|
||||
new JpaQueryParser<>(listQuery.query(), predicates, root, query, builder).build();
|
||||
var queryPredicate = predicates.size() == 1
|
||||
? predicates.get(0)
|
||||
: builder.and(predicates.toArray(Predicate[]::new));
|
||||
return ObjectHelper.isNull(predicate)
|
||||
? queryPredicate
|
||||
: builder.and(predicate, queryPredicate);
|
||||
@@ -268,7 +272,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
*
|
||||
* @param id 实体主键ID
|
||||
*/
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public void remove(Long id) {
|
||||
if (ObjectHelper.isNotNull(id)) {
|
||||
@@ -286,7 +290,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
*
|
||||
* @param ids 实体主键ID集合
|
||||
*/
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public void remove(Set<Long> ids) {
|
||||
if (ObjectHelper.isNotEmpty(ids)) {
|
||||
@@ -295,14 +299,14 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final class JpaQueryParser<ENTITY> extends QueryParser<Predicate> {
|
||||
private static final class JpaQueryParser<ENTITY> extends QueryParser<List<Predicate>> {
|
||||
private final Root<ENTITY> root;
|
||||
@SuppressWarnings({"unused", "FieldCanBeLocal"})
|
||||
private final CriteriaQuery<?> query;
|
||||
private final CriteriaBuilder builder;
|
||||
private final List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
private JpaQueryParser(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
private JpaQueryParser(Query.Queryable queryable, List<Predicate> predicates, Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
super(queryable, predicates);
|
||||
this.root = root;
|
||||
this.query = query;
|
||||
this.builder = builder;
|
||||
@@ -434,17 +438,17 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void nullEqual(Query.Queryable queryable) {
|
||||
protected void nullEqual(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.nullEqual().forEach(column -> predicates.add(builder.isNull(column(root, column))));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notNullEqual(Query.Queryable queryable) {
|
||||
protected void notNullEqual(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.notNullEqual().forEach(column -> predicates.add(builder.isNotNull(column(root, column))));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void empty(Query.Queryable queryable) {
|
||||
protected void empty(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.empty().forEach(column -> {
|
||||
var path = this.<Collection<Object>>column(root, column);
|
||||
checkCollection(path, column);
|
||||
@@ -453,7 +457,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notEmpty(Query.Queryable queryable) {
|
||||
protected void notEmpty(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.notEmpty().forEach(column -> {
|
||||
var path = this.<Collection<Object>>column(root, column);
|
||||
checkCollection(path, column);
|
||||
@@ -462,7 +466,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void equal(Query.Queryable queryable) {
|
||||
protected void equal(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.equal().forEach((column, value) -> {
|
||||
var path = column(root, column);
|
||||
predicates.add(builder.equal(path, value(path, value)));
|
||||
@@ -470,7 +474,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notEqual(Query.Queryable queryable) {
|
||||
protected void notEqual(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.notEqual().forEach((column, value) -> {
|
||||
var path = column(root, column);
|
||||
predicates.add(builder.notEqual(path, value(path, value)));
|
||||
@@ -478,7 +482,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void like(Query.Queryable queryable) {
|
||||
protected void like(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.like().forEach((column, value) -> {
|
||||
var path = this.<String>column(root, column);
|
||||
checkString(path, value, column);
|
||||
@@ -487,7 +491,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notLike(Query.Queryable queryable) {
|
||||
protected void notLike(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.notLike().forEach((column, value) -> {
|
||||
var path = this.<String>column(root, column);
|
||||
checkString(path, value, column);
|
||||
@@ -496,7 +500,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void contain(Query.Queryable queryable) {
|
||||
protected void contain(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.contain().forEach((column, value) -> {
|
||||
var path = this.<String>column(root, column);
|
||||
checkString(path, value, column);
|
||||
@@ -505,7 +509,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notContain(Query.Queryable queryable) {
|
||||
protected void notContain(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.notContain().forEach((column, value) -> {
|
||||
var path = this.<String>column(root, column);
|
||||
checkString(path, value, column);
|
||||
@@ -514,7 +518,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startWith(Query.Queryable queryable) {
|
||||
protected void startWith(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.startWith().forEach((column, value) -> {
|
||||
var path = this.<String>column(root, column);
|
||||
checkString(path, value, column);
|
||||
@@ -523,7 +527,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notStartWith(Query.Queryable queryable) {
|
||||
protected void notStartWith(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.notStartWith().forEach((column, value) -> {
|
||||
var path = this.<String>column(root, column);
|
||||
checkString(path, value, column);
|
||||
@@ -532,7 +536,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endWith(Query.Queryable queryable) {
|
||||
protected void endWith(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.endWith().forEach((column, value) -> {
|
||||
var path = this.<String>column(root, column);
|
||||
checkString(path, value, column);
|
||||
@@ -541,7 +545,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notEndWith(Query.Queryable queryable) {
|
||||
protected void notEndWith(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.notEndWith().forEach((column, value) -> {
|
||||
var path = this.<String>column(root, column);
|
||||
checkString(path, value, column);
|
||||
@@ -550,7 +554,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void great(Query.Queryable queryable) {
|
||||
protected void great(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.great().forEach((column, value) -> {
|
||||
var path = this.<Comparable<Object>>column(root, column);
|
||||
checkComparable(path, value, column);
|
||||
@@ -559,7 +563,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void less(Query.Queryable queryable) {
|
||||
protected void less(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.less().forEach((column, value) -> {
|
||||
var path = this.<Comparable<Object>>column(root, column);
|
||||
checkComparable(path, value, column);
|
||||
@@ -568,7 +572,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void greatEqual(Query.Queryable queryable) {
|
||||
protected void greatEqual(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.greatEqual().forEach((column, value) -> {
|
||||
var path = this.<Comparable<Object>>column(root, column);
|
||||
checkComparable(path, value, column);
|
||||
@@ -577,7 +581,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void lessEqual(Query.Queryable queryable) {
|
||||
protected void lessEqual(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.lessEqual().forEach((column, value) -> {
|
||||
var path = this.<Comparable<Object>>column(root, column);
|
||||
checkComparable(path, value, column);
|
||||
@@ -586,7 +590,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inside(Query.Queryable queryable) {
|
||||
protected void inside(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.inside()
|
||||
.entrySet()
|
||||
.stream()
|
||||
@@ -595,7 +599,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notInside(Query.Queryable queryable) {
|
||||
protected void notInside(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.notInside()
|
||||
.entrySet()
|
||||
.stream()
|
||||
@@ -604,7 +608,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void between(Query.Queryable queryable) {
|
||||
protected void between(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.between().forEach((column, value) -> {
|
||||
var path = this.<Comparable<Object>>column(root, column);
|
||||
checkComparable(path, value, column);
|
||||
@@ -613,19 +617,12 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notBetween(Query.Queryable queryable) {
|
||||
protected void notBetween(Query.Queryable queryable, List<Predicate> predicates) {
|
||||
queryable.notBetween().forEach((column, value) -> {
|
||||
var path = this.<Comparable<Object>>column(root, column);
|
||||
checkComparable(path, value, column);
|
||||
predicates.add(builder.between(path, (Comparable<Object>) value(path, value.start()), (Comparable<Object>) value(path, value.end())).not());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Predicate build() {
|
||||
return predicates.size() == 1
|
||||
? predicates.get(0)
|
||||
: builder.and(predicates.toArray(Predicate[]::new));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,12 @@
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-boot-service-template-xbatis</artifactId>
|
||||
<artifactId>spring-boot-service-template-database-xbatis</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.lanyuanxiaoyao</groupId>
|
||||
<artifactId>spring-boot-service-template-common</artifactId>
|
||||
<artifactId>spring-boot-service-template-database-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -22,27 +22,12 @@
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.xbatis</groupId>
|
||||
<artifactId>xbatis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.gavlyukovskiy</groupId>
|
||||
<artifactId>p6spy-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jspecify</groupId>
|
||||
<artifactId>jspecify</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.lanyuanxiaoyao.service.template.xbatis.controller;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.common.controller.SimpleController;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.GlobalResponse;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.ObjectHelper;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.controller.SimpleController;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.GlobalResponse;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.xbatis.entity.SimpleEntity;
|
||||
import com.lanyuanxiaoyao.service.template.xbatis.service.SimpleServiceSupport;
|
||||
import java.util.function.Function;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.lanyuanxiaoyao.service.template.xbatis.entity;
|
||||
|
||||
import cn.xbatis.core.incrementer.Generator;
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.SnowflakeHelper;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.helper.SnowflakeHelper;
|
||||
|
||||
public class SnowflakeIdGenerator implements Generator<Long> {
|
||||
@Override
|
||||
@@ -3,12 +3,12 @@ package com.lanyuanxiaoyao.service.template.xbatis.service;
|
||||
import cn.xbatis.core.mybatis.mapper.context.Pager;
|
||||
import cn.xbatis.core.sql.MybatisCmdFactory;
|
||||
import cn.xbatis.core.sql.executor.chain.QueryChain;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Page;
|
||||
import com.lanyuanxiaoyao.service.template.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.common.exception.IdNotFoundException;
|
||||
import com.lanyuanxiaoyao.service.template.common.helper.ObjectHelper;
|
||||
import com.lanyuanxiaoyao.service.template.common.service.QueryParser;
|
||||
import com.lanyuanxiaoyao.service.template.common.service.SimpleService;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Page;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.entity.Query;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.exception.IdNotFoundException;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.service.QueryParser;
|
||||
import com.lanyuanxiaoyao.service.template.database.common.service.SimpleService;
|
||||
import com.lanyuanxiaoyao.service.template.xbatis.entity.SimpleEntity;
|
||||
import com.lanyuanxiaoyao.service.template.xbatis.mapper.MybatisBasicMapper;
|
||||
import db.sql.api.cmd.LikeMode;
|
||||
@@ -18,6 +18,8 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mapstruct.Named;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implements SimpleService<ENTITY> {
|
||||
@@ -32,11 +34,13 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public Long save(ENTITY entity) {
|
||||
return (long) mapper.save(entity);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public void save(Iterable<ENTITY> entities) {
|
||||
mapper.save(entities);
|
||||
@@ -79,7 +83,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
|
||||
var where = chain.where();
|
||||
commonPredicates(where);
|
||||
new XBatisQueryParser<>(target, factory, where).build(query.query());
|
||||
new XBatisQueryParser<>(query.query(), where, target, factory).build();
|
||||
|
||||
return new Page<>(chain.list(), chain.count());
|
||||
}
|
||||
@@ -91,129 +95,132 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
return Optional.ofNullable(mapper.getById(target, id));
|
||||
}
|
||||
|
||||
@Named("detail")
|
||||
@Override
|
||||
public ENTITY detail(Long id) {
|
||||
return detailOptional(id).orElse(null);
|
||||
}
|
||||
|
||||
@Named("detailOrThrow")
|
||||
@Override
|
||||
public ENTITY detailOrThrow(Long id) {
|
||||
return detailOptional(id).orElseThrow(() -> new IdNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public void remove(Long id) {
|
||||
mapper.deleteById(target, id);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
@Override
|
||||
public void remove(Set<Long> ids) {
|
||||
mapper.deleteByIds(target, ids);
|
||||
}
|
||||
|
||||
private static final class XBatisQueryParser<ENTITY> extends QueryParser<Void> {
|
||||
private static final class XBatisQueryParser<ENTITY> extends QueryParser<Where> {
|
||||
private final Class<ENTITY> target;
|
||||
private final MybatisCmdFactory factory;
|
||||
private final Where where;
|
||||
|
||||
private XBatisQueryParser(Class<ENTITY> target, MybatisCmdFactory factory, Where where) {
|
||||
private XBatisQueryParser(Query.Queryable queryable, Where where, Class<ENTITY> target, MybatisCmdFactory factory) {
|
||||
super(queryable, where);
|
||||
this.target = target;
|
||||
this.factory = factory;
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void nullEqual(Query.Queryable queryable) {
|
||||
protected void nullEqual(Query.Queryable queryable, Where where) {
|
||||
queryable.nullEqual().forEach(column -> where.isNull(factory.field(target, column)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notNullEqual(Query.Queryable queryable) {
|
||||
protected void notNullEqual(Query.Queryable queryable, Where where) {
|
||||
queryable.notNullEqual().forEach(column -> where.isNotNull(factory.field(target, column)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void empty(Query.Queryable queryable) {
|
||||
protected void empty(Query.Queryable queryable, Where where) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notEmpty(Query.Queryable queryable) {
|
||||
protected void notEmpty(Query.Queryable queryable, Where where) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void equal(Query.Queryable queryable) {
|
||||
protected void equal(Query.Queryable queryable, Where where) {
|
||||
queryable.equal().forEach((column, value) -> where.eq(factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notEqual(Query.Queryable queryable) {
|
||||
protected void notEqual(Query.Queryable queryable, Where where) {
|
||||
queryable.notEqual().forEach((column, value) -> where.ne(factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void like(Query.Queryable queryable) {
|
||||
protected void like(Query.Queryable queryable, Where where) {
|
||||
queryable.like().forEach((column, value) -> where.like(LikeMode.NONE, factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notLike(Query.Queryable queryable) {
|
||||
protected void notLike(Query.Queryable queryable, Where where) {
|
||||
queryable.notLike().forEach((column, value) -> where.notLike(LikeMode.NONE, factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void contain(Query.Queryable queryable) {
|
||||
protected void contain(Query.Queryable queryable, Where where) {
|
||||
queryable.contain().forEach((column, value) -> where.like(factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notContain(Query.Queryable queryable) {
|
||||
protected void notContain(Query.Queryable queryable, Where where) {
|
||||
queryable.notContain().forEach((column, value) -> where.notLike(factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startWith(Query.Queryable queryable) {
|
||||
protected void startWith(Query.Queryable queryable, Where where) {
|
||||
queryable.startWith().forEach((column, value) -> where.like(LikeMode.LEFT, factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notStartWith(Query.Queryable queryable) {
|
||||
protected void notStartWith(Query.Queryable queryable, Where where) {
|
||||
queryable.notStartWith().forEach((column, value) -> where.notLike(LikeMode.LEFT, factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endWith(Query.Queryable queryable) {
|
||||
protected void endWith(Query.Queryable queryable, Where where) {
|
||||
queryable.endWith().forEach((column, value) -> where.like(LikeMode.RIGHT, factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notEndWith(Query.Queryable queryable) {
|
||||
protected void notEndWith(Query.Queryable queryable, Where where) {
|
||||
queryable.notEndWith().forEach((column, value) -> where.notLike(LikeMode.RIGHT, factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void great(Query.Queryable queryable) {
|
||||
protected void great(Query.Queryable queryable, Where where) {
|
||||
queryable.great().forEach((column, value) -> where.gt(factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void less(Query.Queryable queryable) {
|
||||
protected void less(Query.Queryable queryable, Where where) {
|
||||
queryable.less().forEach((column, value) -> where.lt(factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void greatEqual(Query.Queryable queryable) {
|
||||
protected void greatEqual(Query.Queryable queryable, Where where) {
|
||||
queryable.greatEqual().forEach((column, value) -> where.gte(factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void lessEqual(Query.Queryable queryable) {
|
||||
protected void lessEqual(Query.Queryable queryable, Where where) {
|
||||
queryable.lessEqual().forEach((column, value) -> where.lte(factory.field(target, column), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inside(Query.Queryable queryable) {
|
||||
protected void inside(Query.Queryable queryable, Where where) {
|
||||
queryable.inside()
|
||||
.entrySet()
|
||||
.stream()
|
||||
@@ -222,7 +229,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notInside(Query.Queryable queryable) {
|
||||
protected void notInside(Query.Queryable queryable, Where where) {
|
||||
queryable.notInside()
|
||||
.entrySet()
|
||||
.stream()
|
||||
@@ -231,18 +238,13 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void between(Query.Queryable queryable) {
|
||||
protected void between(Query.Queryable queryable, Where where) {
|
||||
queryable.between().forEach((column, value) -> where.between(factory.field(target, column), value.start(), value.end()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notBetween(Query.Queryable queryable) {
|
||||
protected void notBetween(Query.Queryable queryable, Where where) {
|
||||
queryable.notBetween().forEach((column, value) -> where.notBetween(factory.field(target, column), value.start(), value.end()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void build() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ spring:
|
||||
application:
|
||||
name: Test
|
||||
datasource:
|
||||
url: "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=MySQL;DATABASE_TO_LOWER=TRUE;INIT=runscript from '/Users/lanyuanxiaoyao/Project/IdeaProjects/spring-boot-service-template/spring-boot-service-template-xbatis/src/test/initial.sql'"
|
||||
url: "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=MySQL;DATABASE_TO_LOWER=TRUE;INIT=runscript from '/Users/lanyuanxiaoyao/Project/IdeaProjects/spring-boot-service-template/spring-boot-service-template-database/spring-boot-service-template-database-xbatis/src/test/initial.sql'"
|
||||
username: test
|
||||
password: test
|
||||
driver-class-name: org.h2.Driver
|
||||
Reference in New Issue
Block a user