feat: 增加字符串判断的简便参数
This commit is contained in:
@@ -122,6 +122,30 @@ public class Query {
|
|||||||
* 指定字段不模糊匹配的条件映射(字段名 -> 匹配值)
|
* 指定字段不模糊匹配的条件映射(字段名 -> 匹配值)
|
||||||
*/
|
*/
|
||||||
private Map<String, String> notLike;
|
private Map<String, String> notLike;
|
||||||
|
/**
|
||||||
|
* 指定字段包含指定字符串的条件映射(字段名 -> 包含值)
|
||||||
|
*/
|
||||||
|
private Map<String, String> contain;
|
||||||
|
/**
|
||||||
|
* 指定字段不包含指定字符串的条件映射(字段名 -> 不包含值)
|
||||||
|
*/
|
||||||
|
private Map<String, String> notContain;
|
||||||
|
/**
|
||||||
|
* 指定字段以指定字符串开头的条件映射(字段名 -> 开头值)
|
||||||
|
*/
|
||||||
|
private Map<String, String> startWith;
|
||||||
|
/**
|
||||||
|
* 指定字段不以指定字符串开头的条件映射(字段名 -> 不开头值)
|
||||||
|
*/
|
||||||
|
private Map<String, String> notStartWith;
|
||||||
|
/**
|
||||||
|
* 指定字段以指定字符串结尾的条件映射(字段名 -> 结尾值)
|
||||||
|
*/
|
||||||
|
private Map<String, String> endWith;
|
||||||
|
/**
|
||||||
|
* 指定字段不以指定字符串结尾的条件映射(字段名 -> 不结尾值)
|
||||||
|
*/
|
||||||
|
private Map<String, String> notEndWith;
|
||||||
/**
|
/**
|
||||||
* 指定字段大于条件的映射(字段名 -> 值)
|
* 指定字段大于条件的映射(字段名 -> 值)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
|||||||
if (ObjectHelper.isEmpty(column)) {
|
if (ObjectHelper.isEmpty(column)) {
|
||||||
throw new IllegalArgumentException("Column cannot be blank");
|
throw new IllegalArgumentException("Column cannot be blank");
|
||||||
}
|
}
|
||||||
var columns = column.split("/");
|
var columns = column.split("\\.");
|
||||||
Path<Y> path = root.get(columns[0]);
|
Path<Y> path = root.get(columns[0]);
|
||||||
for (int i = 1; i < columns.length; i++) {
|
for (int i = 1; i < columns.length; i++) {
|
||||||
path = path.get(columns[i]);
|
path = path.get(columns[i]);
|
||||||
@@ -282,6 +282,48 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
|||||||
predicates.add(builder.notLike(column(root, column), value));
|
predicates.add(builder.notLike(column(root, column), value));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (ObjectHelper.isNotEmpty(queryable.getContain())) {
|
||||||
|
queryable.getContain().forEach((column, value) -> {
|
||||||
|
var path = this.<String>column(root, column);
|
||||||
|
checkString(path, value, column);
|
||||||
|
predicates.add(builder.like(column(root, column), "%" + value + "%"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (ObjectHelper.isNotEmpty(queryable.getNotContain())) {
|
||||||
|
queryable.getNotContain().forEach((column, value) -> {
|
||||||
|
var path = this.<String>column(root, column);
|
||||||
|
checkString(path, value, column);
|
||||||
|
predicates.add(builder.notLike(column(root, column), "%" + value + "%"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (ObjectHelper.isNotEmpty(queryable.getStartWith())) {
|
||||||
|
queryable.getStartWith().forEach((column, value) -> {
|
||||||
|
var path = this.<String>column(root, column);
|
||||||
|
checkString(path, value, column);
|
||||||
|
predicates.add(builder.like(column(root, column), value + "%"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (ObjectHelper.isNotEmpty(queryable.getNotStartWith())) {
|
||||||
|
queryable.getNotStartWith().forEach((column, value) -> {
|
||||||
|
var path = this.<String>column(root, column);
|
||||||
|
checkString(path, value, column);
|
||||||
|
predicates.add(builder.notLike(column(root, column), value + "%"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (ObjectHelper.isNotEmpty(queryable.getEndWith())) {
|
||||||
|
queryable.getEndWith().forEach((column, value) -> {
|
||||||
|
var path = this.<String>column(root, column);
|
||||||
|
checkString(path, value, column);
|
||||||
|
predicates.add(builder.like(column(root, column), "%" + value));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (ObjectHelper.isNotEmpty(queryable.getNotEndWith())) {
|
||||||
|
queryable.getNotEndWith().forEach((column, value) -> {
|
||||||
|
var path = this.<String>column(root, column);
|
||||||
|
checkString(path, value, column);
|
||||||
|
predicates.add(builder.notLike(column(root, column), "%" + value));
|
||||||
|
});
|
||||||
|
}
|
||||||
if (ObjectHelper.isNotEmpty(queryable.getGreat())) {
|
if (ObjectHelper.isNotEmpty(queryable.getGreat())) {
|
||||||
queryable.getGreat().forEach((column, value) -> {
|
queryable.getGreat().forEach((column, value) -> {
|
||||||
var path = this.<Comparable<Object>>column(root, column);
|
var path = this.<Comparable<Object>>column(root, column);
|
||||||
|
|||||||
Reference in New Issue
Block a user