use of org.sagacity.sqltoy.model.ParamsFilter in project sagacity-sqltoy by chenrenfei.
the class ParamFilterUtils method combineFilters.
/**
* @TODO 整合sql中定义的filter和代码中自定义的filters
* @param filters
* @param extFilters
* @return
*/
public static List<ParamFilterModel> combineFilters(List<ParamFilterModel> filters, List<ParamsFilter> extFilters) {
if (extFilters == null || extFilters.isEmpty()) {
return filters;
}
List<ParamFilterModel> result = new ArrayList<ParamFilterModel>();
if (filters != null && !filters.isEmpty()) {
result.addAll(filters);
}
for (ParamsFilter filter : extFilters) {
ParamFilterModel paramFilter = new ParamFilterModel();
paramFilter.setFilterType(filter.getType());
paramFilter.setParams(filter.getParams());
if (filter.getParams().length == 1) {
paramFilter.setParam(filter.getParams()[0]);
}
if (filter.getExcludes() != null) {
for (String s : filter.getExcludes()) {
paramFilter.addExclude(s);
}
}
paramFilter.setFormat(filter.getDateType());
paramFilter.setValues(filter.getValue());
// 加减天数
paramFilter.setIncrementTime(Double.valueOf(filter.getIncrease()));
paramFilter.setTimeUnit(filter.getTimeUnit());
result.add(paramFilter);
}
return result;
}
Aggregations