feat: 解决查询条件string有传""的情况,这种情况直接忽略

This commit is contained in:
lilong 2024-03-26 16:49:41 +08:00
parent 0bfd1ef217
commit 4b0d92cbe9
2 changed files with 12 additions and 0 deletions

View File

@ -32,6 +32,12 @@ public @interface CriteriaField {
*/
boolean filterNull() default true;
/**
* 默认为true当value为""的时候自动过滤该查询条件.
* @return
*/
boolean filterBlank() default true;
/**
* 是否忽略该字段的查询条件
*

View File

@ -338,6 +338,12 @@ public class CriteriaWrapper {
return null;
}
if (fieldAnnotation.filterBlank()
&& (value instanceof String)
&& StringUtils.isBlank((String) value)) {
return null;
}
String fieldName = Strings.isNullOrEmpty(fieldAnnotation.field()) ? field : fieldAnnotation.field();
// XXX 注解中获取的operator如果为EQ无法判断是用户手动设置为EQ还是使用的默认operator.EQ这里暂时保持原状
return build(fieldName, fieldAnnotation.operator(), value, fieldAnnotation.prefix());