diff --git a/pom.xml b/pom.xml
index db25bfa615dbf3bfd8004f33aadae8310f9124cb..0703f62befa9ce50a313506904cb59a3aa3ed44c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
4.0.0
com.fhs-opensource
jpa-query-wrapper
- 1.0.3
+ 1.0.4
UTF-8
diff --git a/src/main/java/com/fhs/jpa/wrapper/AbstractWrapper.java b/src/main/java/com/fhs/jpa/wrapper/AbstractWrapper.java
index 32dd51af304de5f18bb92c85d9366a08c0c3fea3..e4d67d8e6e56410b795acabef42468ed610fdbf9 100644
--- a/src/main/java/com/fhs/jpa/wrapper/AbstractWrapper.java
+++ b/src/main/java/com/fhs/jpa/wrapper/AbstractWrapper.java
@@ -6,6 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.jpa.domain.Specification;
import javax.persistence.criteria.*;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -109,6 +110,17 @@ public class AbstractWrapper {
return criteriaBuilder.isNull(root.get(predicate.getFieldName()));
case NOTNULL:
return criteriaBuilder.isNotNull(root.get(predicate.getFieldName()));
+ case GREATERTHAN:
+ return criteriaBuilder.greaterThan(root.get(predicate.getFieldName()), (Comparable) predicate.getValue());
+ case GREATERTHANOREQUALTO:
+ return criteriaBuilder.greaterThanOrEqualTo(root.get(predicate.getFieldName()), (Comparable) predicate.getValue());
+ case LESSTHAN:
+ return criteriaBuilder.lessThan(root.get(predicate.getFieldName()), (Comparable) predicate.getValue());
+ case LESSTHANOREQUALTO:
+ return criteriaBuilder.lessThanOrEqualTo(root.get(predicate.getFieldName()), (Comparable)predicate.getValue());
+ case BETWEEN:
+ Object[] objPair = (Object[])predicate.getValue();
+ return criteriaBuilder.between(root.get(predicate.getFieldName()), (Comparable)objPair[0], (Comparable)objPair[1]);
}
return null;
}
@@ -153,5 +165,5 @@ class TempPredicate {
}
enum Operator {
- EQ, LIKE, NE, GE, GT, LE, LT, IN, NOTLIKE, BETWEEN, NOTIN,ISNULL,NOTNULL;
+ EQ, LIKE, NE, GE, GT, LE, LT, IN, NOTLIKE, BETWEEN, NOTIN,ISNULL,NOTNULL,GREATERTHAN,GREATERTHANOREQUALTO,LESSTHAN,LESSTHANOREQUALTO;
}
diff --git a/src/main/java/com/fhs/jpa/wrapper/LambdaQueryWrapper.java b/src/main/java/com/fhs/jpa/wrapper/LambdaQueryWrapper.java
index ab151c574bfb9df941be2bb0202895548839fa7c..47534304e33275326f202293e56294d27c488fbf 100644
--- a/src/main/java/com/fhs/jpa/wrapper/LambdaQueryWrapper.java
+++ b/src/main/java/com/fhs/jpa/wrapper/LambdaQueryWrapper.java
@@ -194,6 +194,118 @@ public class LambdaQueryWrapper extends AbstractWrapper{
return this;
}
+ /**
+ * >
+ *
+ * @param fieldLambda lambda
+ * @param value 值
+ * @return this
+ */
+ public LambdaQueryWrapper greaterThan(SFunction fieldLambda, Comparable> value) {
+ greaterThan(true, fieldLambda, value);
+ return this;
+ }
+
+ /**
+ * >
+ *
+ * @param condition 是否需要使用本条件
+ * @param fieldLambda lambda
+ * @param value 值
+ * @return this
+ */
+ public LambdaQueryWrapper greaterThan(boolean condition, SFunction fieldLambda, Comparable> value) {
+ if (condition) {
+ tempPredicates.add(TempPredicate.builder().fieldName(fieldLambda2FieldName(fieldLambda))
+ .operator(Operator.GREATERTHAN).value(value).build());
+ }
+ return this;
+ }
+
+ /**
+ * >=
+ *
+ * @param fieldLambda lambda
+ * @param value 值
+ * @return this
+ */
+ public LambdaQueryWrapper greaterThanOrEqualTo(SFunction fieldLambda, Comparable> value) {
+ greaterThanOrEqualTo(true, fieldLambda, value);
+ return this;
+ }
+
+ /**
+ * >=
+ *
+ * @param condition 是否需要使用本条件
+ * @param fieldLambda lambda
+ * @param value 值
+ * @return this
+ */
+ public LambdaQueryWrapper greaterThanOrEqualTo(boolean condition, SFunction fieldLambda, Comparable> value) {
+ if (condition) {
+ tempPredicates.add(TempPredicate.builder().fieldName(fieldLambda2FieldName(fieldLambda))
+ .operator(Operator.GREATERTHANOREQUALTO).value(value).build());
+ }
+ return this;
+ }
+
+ /**
+ * <
+ *
+ * @param fieldLambda lambda
+ * @param value 值
+ * @return this
+ */
+ public LambdaQueryWrapper lessThan(SFunction fieldLambda, Comparable> value) {
+ lessThan(true, fieldLambda, value);
+ return this;
+ }
+
+ /**
+ * <
+ *
+ * @param condition 是否需要使用本条件
+ * @param fieldLambda lambda
+ * @param value 值
+ * @return this
+ */
+ public LambdaQueryWrapper lessThan(boolean condition, SFunction fieldLambda, Comparable> value) {
+ if (condition) {
+ tempPredicates.add(TempPredicate.builder().fieldName(fieldLambda2FieldName(fieldLambda))
+ .operator(Operator.LESSTHAN).value(value).build());
+ }
+ return this;
+ }
+
+ /**
+ * <=
+ *
+ * @param fieldLambda lambda
+ * @param value 值
+ * @return this
+ */
+ public LambdaQueryWrapper lessThanOrEqualTo(SFunction fieldLambda, Comparable> value) {
+ lessThanOrEqualTo(true, fieldLambda, value);
+ return this;
+ }
+
+ /**
+ * <=
+ *
+ * @param condition 是否需要使用本条件
+ * @param fieldLambda lambda
+ * @param value 值
+ * @return this
+ */
+ public LambdaQueryWrapper lessThanOrEqualTo(boolean condition, SFunction fieldLambda, Comparable> value) {
+ if (condition) {
+ tempPredicates.add(TempPredicate.builder().fieldName(fieldLambda2FieldName(fieldLambda))
+ .operator(Operator.LESSTHANOREQUALTO).value(value).build());
+ }
+ return this;
+ }
+
/**
* like '%xx%'
*
diff --git a/src/main/java/com/fhs/jpa/wrapper/QueryWrapper.java b/src/main/java/com/fhs/jpa/wrapper/QueryWrapper.java
index f2a76d28a8f492d8a22937452cf5dfc38112d22e..ccce97764673b166ff3d360b85092863a95fd50a 100644
--- a/src/main/java/com/fhs/jpa/wrapper/QueryWrapper.java
+++ b/src/main/java/com/fhs/jpa/wrapper/QueryWrapper.java
@@ -176,6 +176,119 @@ public class QueryWrapper extends AbstractWrapper {
return this;
}
+
+ /**
+ * >
+ *
+ * @param fieldName 字段名
+ * @param value 值
+ * @return this
+ */
+ public QueryWrapper greaterThan(String fieldName, Comparable> value) {
+ greaterThan(true, fieldName, value);
+ return this;
+ }
+
+ /**
+ * >
+ *
+ * @param condition 是否需要使用本条件
+ * @param fieldName 字段名
+ * @param value 值
+ * @return this
+ */
+ public QueryWrapper greaterThan(boolean condition, String fieldName, Comparable> value) {
+ if (condition) {
+ tempPredicates.add(TempPredicate.builder().fieldName(fieldName)
+ .operator(Operator.GREATERTHAN).value(value).build());
+ }
+ return this;
+ }
+
+ /**
+ * >=
+ *
+ * @param fieldName 字段名
+ * @param value 值
+ * @return this
+ */
+ public QueryWrapper greaterThanOrEqualTo(String fieldName, Comparable> value) {
+ greaterThanOrEqualTo(true, fieldName, value);
+ return this;
+ }
+
+ /**
+ * >=
+ *
+ * @param condition 是否需要使用本条件
+ * @param fieldName 字段名
+ * @param value 值
+ * @return this
+ */
+ public QueryWrapper greaterThanOrEqualTo(boolean condition, String fieldName, Comparable> value) {
+ if (condition) {
+ tempPredicates.add(TempPredicate.builder().fieldName(fieldName)
+ .operator(Operator.GREATERTHANOREQUALTO).value(value).build());
+ }
+ return this;
+ }
+
+ /**
+ * <
+ *
+ * @param fieldName 字段名
+ * @param value 值
+ * @return this
+ */
+ public QueryWrapper lessThan(String fieldName, Comparable> value) {
+ lessThan(true, fieldName, value);
+ return this;
+ }
+
+ /**
+ * <
+ *
+ * @param condition 是否需要使用本条件
+ * @param fieldName 字段名
+ * @param value 值
+ * @return this
+ */
+ public QueryWrapper lessThan(boolean condition, String fieldName, Comparable> value) {
+ if (condition) {
+ tempPredicates.add(TempPredicate.builder().fieldName(fieldName)
+ .operator(Operator.LESSTHAN).value(value).build());
+ }
+ return this;
+ }
+
+ /**
+ * <=
+ *
+ * @param fieldName 字段名
+ * @param value 值
+ * @return this
+ */
+ public QueryWrapper lessThanOrEqualTo(String fieldName, Comparable> value) {
+ lessThanOrEqualTo(true, fieldName, value);
+ return this;
+ }
+
+ /**
+ * <=
+ *
+ * @param condition 是否需要使用本条件
+ * @param fieldName 字段名
+ * @param value 值
+ * @return this
+ */
+ public QueryWrapper lessThanOrEqualTo(boolean condition, String fieldName, Comparable> value) {
+ if (condition) {
+ tempPredicates.add(TempPredicate.builder().fieldName(fieldName)
+ .operator(Operator.LESSTHANOREQUALTO).value(value).build());
+ }
+ return this;
+ }
+
/**
* like '%xx%'
*