|
@@ -82,30 +82,30 @@ public class SearchBuilder {
|
|
|
return (root, query, cb) -> cb.lessThanOrEqualTo(root.get(fieldName), (Comparable) value);
|
|
|
}
|
|
|
|
|
|
- public <T> SearchBuilder like(String fieldName, T value) {
|
|
|
+ public SearchBuilder like(String fieldName, CharSequence value) {
|
|
|
searchers.add(new Searcher(fieldName, value, Op.LIKE));
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public static <T> Specification LIKE(String fieldName, T value) {
|
|
|
+ public static Specification LIKE(String fieldName, CharSequence value) {
|
|
|
return (root, query, cb) -> cb.like(root.get(fieldName), "%" + value + "%");
|
|
|
}
|
|
|
|
|
|
- public <T> SearchBuilder leftLike(String fieldName, T value) {
|
|
|
+ public SearchBuilder leftLike(String fieldName, CharSequence value) {
|
|
|
searchers.add(new Searcher(fieldName, value, Op.L_LIKE));
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public static <T> Specification L_LIKE(String fieldName, T value) {
|
|
|
+ public static Specification L_LIKE(String fieldName, CharSequence value) {
|
|
|
return (root, query, cb) -> cb.like(root.get(fieldName), "%" + value);
|
|
|
}
|
|
|
|
|
|
- public <T> SearchBuilder rightLike(String fieldName, T value) {
|
|
|
+ public SearchBuilder rightLike(String fieldName, CharSequence value) {
|
|
|
searchers.add(new Searcher(fieldName, value, Op.R_LIKE));
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public static <T> Specification R_LIKE(String fieldName, T value) {
|
|
|
+ public static Specification R_LIKE(String fieldName, CharSequence value) {
|
|
|
return (root, query, cb) -> cb.like(root.get(fieldName), value + "%");
|
|
|
}
|
|
|
|
|
@@ -171,6 +171,10 @@ public class SearchBuilder {
|
|
|
return (root, query, cb) -> cb.isNotNull(root.get(fieldName));
|
|
|
}
|
|
|
|
|
|
+ public static <T> Specification between(String fieldName, T start, T end) {
|
|
|
+ return (root, query, cb) -> cb.between(root.get(fieldName), (Comparable) start, (Comparable) end);
|
|
|
+ }
|
|
|
+
|
|
|
public static class Searcher<T> {
|
|
|
/**
|
|
|
* 属性名
|