提交 b2a26b08 编写于 作者: chenxiang@lab.ibiz5.com's avatar chenxiang@lab.ibiz5.com

接口实体SearchContext

上级 86c20d6d
......@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map;
import java.util.HashMap;
import cn.ibizlab.util.filter.SearchContextBase;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
......@@ -35,7 +36,7 @@ import {{packageName}}.core.{{entity.module}}.domain.{{entity.codeName}};
@Setter
@NoArgsConstructor
@ApiModel("{{entity.logicName}}")
public class {{entity.codeName}}SearchContext extends QueryWrapperContext<{{entity.codeName}}> {
public class {{entity.codeName}}SearchContext extends SearchContextBase {
{{#each entity.fields as |field|}}
{{#each field.allPSDEFSearchModes as |formitem|}}
......@@ -56,90 +57,6 @@ public class {{entity.codeName}}SearchContext extends QueryWrapperContext<{{enti
private {{#if (or (eq formitem.valueOP "IN") (eq formitem.valueOP "ISNULL") (eq formitem.valueOP "ISNOTNULL"))}}String{{else}}{{field.type.java}}{{/if}} {{camelCase field.codeName}}{{formitem.valueOP}};
public {{entity.codeName}}SearchContext set{{pascalCase field.codeName}}{{formitem.valueOP}}({{#if (or (eq formitem.valueOP "IN") (eq formitem.valueOP "ISNULL") (eq formitem.valueOP "ISNOTNULL"))}}String{{else}}{{field.type.java}}{{/if}} {{camelCase field.codeName}}{{formitem.valueOP}}) {
this.{{camelCase field.codeName}}{{formitem.valueOP}} = {{camelCase field.codeName}}{{formitem.valueOP}};
if(!ObjectUtils.isEmpty(this.{{camelCase field.codeName}}{{formitem.valueOP}})){
{{#eq formitem.valueOP "LIKE"}}
this.getSearchCond().like("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "LEFTLIKE"}}
this.getSearchCond().likeRight("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "RIGHTLIKE"}}
this.getSearchCond().likeLeft("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "EQ"}}
this.getSearchCond().eq("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "NOTEQ"}}
this.getSearchCond().ne("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "GT"}}
this.getSearchCond().gt("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "GTANDEQ"}}
this.getSearchCond().ge("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "LT"}}
this.getSearchCond().lt("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "LTANDEQ"}}
this.getSearchCond().le("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "ISNOTNULL"}}
if(this.{{camelCase field.codeName}}{{formitem.valueOP}}.equals("1")){
this.getSearchCond().isNotNull("{{lowerCase field.name}}");
}
{{/eq}}
{{#eq formitem.valueOP "ISNULL"}}
if(this.{{camelCase field.codeName}}{{formitem.valueOP}}.equals("1")){
this.getSearchCond().isNull("{{lowerCase field.name}}");
}
{{/eq}}
{{#eq formitem.valueOP "IN"}}
this.getSearchCond().in("{{lowerCase field.name}}",this.{{camelCase field.codeName}}{{formitem.valueOP}}.split(";|,|;|,"));
{{/eq}}
{{#eq formitem.valueOP "NOTIN"}}
this.getSearchCond().notIn("{{lowerCase field.name}}",this.{{camelCase field.codeName}}{{formitem.valueOP}}.split(";|,|;|,"));
{{/eq}}
{{#if entity.enableES}}
{{#eq formitem.valueOP "LIKE"}}
this.getEsCond().must(QueryBuilders.wildcardQuery("{{lowerCase field.name}}", String.format("*%s*",{{camelCase field.codeName}}{{formitem.valueOP}})));
{{/eq}}
{{#eq formitem.valueOP "LEFTLIKE"}}
this.getEsCond().must(QueryBuilders.wildcardQuery("{{lowerCase field.name}}", String.format("%s*",{{camelCase field.codeName}}{{formitem.valueOP}})));
{{/eq}}
{{#eq formitem.valueOP "RIGHTLIKE"}}
this.getEsCond().must(QueryBuilders.wildcardQuery("{{lowerCase field.name}}", String.format("*%s",{{camelCase field.codeName}}{{formitem.valueOP}})));
{{/eq}}
{{#eq formitem.valueOP "EQ"}}
this.getEsCond().must(QueryBuilders.termQuery("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "NOTEQ"}}
this.getEsCond().mustNot(QueryBuilders.termQuery("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "GT"}}
this.getEsCond().must(QueryBuilders.rangeQuery("{{lowerCase field.name}}").gt({{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "GTANDEQ"}}
this.getEsCond().must(QueryBuilders.rangeQuery("{{lowerCase field.name}}").gte({{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "LT"}}
this.getEsCond().must(QueryBuilders.rangeQuery("{{lowerCase field.name}}").lt({{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "LTANDEQ"}}
this.getEsCond().must(QueryBuilders.rangeQuery("{{lowerCase field.name}}").lte({{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "ISNOTNULL"}}
if(this.{{camelCase field.codeName}}{{formitem.valueOP}}.equals("1")){
this.getEsCond().mustNot(QueryBuilders.existsQuery("{{lowerCase field.name}}"));
}
{{/eq}}
{{#eq formitem.valueOP "ISNULL"}}
if(this.{{camelCase field.codeName}}{{formitem.valueOP}}.equals("1")){
this.getEsCond().must(QueryBuilders.existsQuery("{{lowerCase field.name}}"));
}
{{/eq}}
{{/if}}
}
return this;
}
{{/each}}
......@@ -151,18 +68,5 @@ public class {{entity.codeName}}SearchContext extends QueryWrapperContext<{{enti
public void setQuery(String query)
{
this.query=query;
if(!StringUtils.isEmpty(query)){
{{#each entity.quickSearchFields as |field|}}
{{#if @first}}
this.getSearchCond().and( wrapper ->
wrapper.like("{{lowerCase field.name}}", query)
{{else}}
.or().like("{{lowerCase field.name}}", query)
{{/if}}
{{#if @last}}
);
{{/if}}
{{/each}}
}
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册