提交 571d4ed0 编写于 作者: xignzi's avatar xignzi

修复.eq .in等相关查询条件值未设置异常

上级 0390107b
...@@ -51,23 +51,22 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -51,23 +51,22 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
@Override @Override
public void init(IDEMethodDTORuntime iDEMethodDTORuntime, Object objData, boolean bDTOData) throws Exception { public void init(IDEMethodDTORuntime iDEMethodDTORuntime, Object objData, boolean bDTOData) throws Exception {
if(!(iDEMethodDTORuntime instanceof IDEFilterDTORuntime)) { if (!(iDEMethodDTORuntime instanceof IDEFilterDTORuntime)) {
throw new Exception(String.format("传入实体方法DTO运行时对象不正确")); throw new Exception(String.format("传入实体方法DTO运行时对象不正确"));
} }
if(!bDTOData) { if (!bDTOData) {
throw new Exception(String.format("仅支持传入DTO")); throw new Exception(String.format("仅支持传入DTO"));
} }
this.iDEFilterDTORuntime = (IDEFilterDTORuntime)iDEMethodDTORuntime; this.iDEFilterDTORuntime = (IDEFilterDTORuntime) iDEMethodDTORuntime;
if (objData instanceof Map) { if (objData instanceof Map) {
Map<String,Object> map = (Map<String,Object>)objData; Map<String, Object> map = (Map<String, Object>) objData;
for(java.util.Map.Entry<String, Object> entry : map.entrySet()) { for (java.util.Map.Entry<String, Object> entry : map.entrySet()) {
if(entry.getKey().equalsIgnoreCase("searchconds")&&(!ObjectUtils.isEmpty(entry.getValue()))) if (entry.getKey().equalsIgnoreCase("searchconds") && (!ObjectUtils.isEmpty(entry.getValue()))) {
{ List list = (List) entry.getValue();
List list=(List)entry.getValue(); if (!(list.get(0) instanceof ISearchCond))
if(!(list.get(0) instanceof ISearchCond))
continue; continue;
} }
...@@ -79,35 +78,33 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -79,35 +78,33 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
} }
protected void onInit() throws Exception { protected void onInit() throws Exception {
Object objSearchConds = this.getSearchConds(); Object objSearchConds = this.getSearchConds();
if(objSearchConds != null) { if (objSearchConds != null) {
//实际展开条件 //实际展开条件
if(objSearchConds instanceof List) { if (objSearchConds instanceof List) {
List list = new ArrayList(); List list = new ArrayList();
((List) objSearchConds).forEach(objItem->{ ((List) objSearchConds).forEach(objItem -> {
if(!(objItem instanceof Map)) { if (!(objItem instanceof Map)) {
return; return;
} }
list.add(objItem); list.add(objItem);
}); });
for(Object objItem : list) { for (Object objItem : list) {
ISearchCond iSearchCond = net.ibizsys.central.util.SearchGroupCond.getSearchCond((Map)objItem, true); ISearchCond iSearchCond = net.ibizsys.central.util.SearchGroupCond.getSearchCond((Map) objItem, true);
if(iSearchCond != null) { if (iSearchCond != null) {
this.getSearchCondsIf().add(iSearchCond); this.getSearchCondsIf().add(iSearchCond);
} }
} }
} }
} }
if(this.getDEMethodDTORuntime()!=null) { if (this.getDEMethodDTORuntime() != null) {
//计算查询条件 //计算查询条件
java.util.List<IPSDEFilterDTOField> psDEFilterDTOFieldList = this.getDEMethodDTORuntime().getPSDEFilterDTO().getPSDEFilterDTOFields(); java.util.List<IPSDEFilterDTOField> psDEFilterDTOFieldList = this.getDEMethodDTORuntime().getPSDEFilterDTO().getPSDEFilterDTOFields();
if(psDEFilterDTOFieldList != null) { if (psDEFilterDTOFieldList != null) {
for(IPSDEFilterDTOField iPSDEFilterDTOField : psDEFilterDTOFieldList) { for (IPSDEFilterDTOField iPSDEFilterDTOField : psDEFilterDTOFieldList) {
Object objValue = this.get(iPSDEFilterDTOField.getLowerCaseName()); Object objValue = this.get(iPSDEFilterDTOField.getLowerCaseName());
if(ObjectUtils.isEmpty(objValue)) { if (ObjectUtils.isEmpty(objValue)) {
continue; continue;
} }
...@@ -118,21 +115,21 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -118,21 +115,21 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
searchFieldCond.setValue(iPSDEFilterDTOField.getLowerCaseName()); searchFieldCond.setValue(iPSDEFilterDTOField.getLowerCaseName());
searchFieldCond.setDataType(iPSDEFilterDTOField.getStdDataType()); searchFieldCond.setDataType(iPSDEFilterDTOField.getStdDataType());
searchFieldCond.setValueFunc(iPSDEFilterDTOField.getPSDEFSearchModeMust().getValueFunc()); searchFieldCond.setValueFunc(iPSDEFilterDTOField.getPSDEFSearchModeMust().getValueFunc());
if(StringUtils.isEmpty(searchFieldCond.getValueFunc())&&hasFieldCond(iPSDEFilterDTOField.getLowerCaseName())) if (StringUtils.isEmpty(searchFieldCond.getValueFunc()) && hasFieldCond(iPSDEFilterDTOField.getLowerCaseName()))
continue; continue;
this.getSearchCondsIf().add(searchFieldCond); this.getSearchCondsIf().add(searchFieldCond);
} }
} }
if(!ObjectUtils.isEmpty(query)) { if (!ObjectUtils.isEmpty(query)) {
//获取所有支持快速搜索的属性 //获取所有支持快速搜索的属性
List<IPSDEField> psDEFieldList = this.getDEMethodDTORuntime().getDataEntityRuntime().getQuickSearchPSDEFields(); List<IPSDEField> psDEFieldList = this.getDEMethodDTORuntime().getDataEntityRuntime().getQuickSearchPSDEFields();
if(psDEFieldList != null && psDEFieldList.size() > 0) { if (psDEFieldList != null && psDEFieldList.size() > 0) {
SearchGroupCond searchGroupCond = new SearchGroupCond(); SearchGroupCond searchGroupCond = new SearchGroupCond();
searchGroupCond.setCondOp(Conditions.OR); searchGroupCond.setCondOp(Conditions.OR);
for(IPSDEField iPSDEField: psDEFieldList ) { for (IPSDEField iPSDEField : psDEFieldList) {
SearchFieldCond searchFieldCond = new SearchFieldCond(); SearchFieldCond searchFieldCond = new SearchFieldCond();
searchFieldCond.setFieldName(iPSDEField.getName()); searchFieldCond.setFieldName(iPSDEField.getName());
searchFieldCond.setParamMode(true); searchFieldCond.setParamMode(true);
...@@ -151,9 +148,9 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -151,9 +148,9 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
} }
Object predefinedcond = this.get(PARAM_PREDEFINEDCOND); Object predefinedcond = this.get(PARAM_PREDEFINEDCOND);
if(predefinedcond instanceof String) { if (predefinedcond instanceof String) {
if(!ObjectUtils.isEmpty(predefinedcond)) { if (!ObjectUtils.isEmpty(predefinedcond)) {
SearchContextDTO.addSearchPredefinedCond(this, (String)predefinedcond, null); SearchContextDTO.addSearchPredefinedCond(this, (String) predefinedcond, null);
} }
} }
} }
...@@ -174,16 +171,18 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -174,16 +171,18 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
private List<ISearchCond> searchconds = null; private List<ISearchCond> searchconds = null;
@Override @Override
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
public List<ISearchCond> getSearchConds() { public List<ISearchCond> getSearchConds() {
return searchconds; return searchconds;
} }
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
public List<ISearchCond> getSearchCondsIf() { public List<ISearchCond> getSearchCondsIf() {
if(this.searchconds == null) { if (this.searchconds == null) {
this.searchconds = new ArrayList<ISearchCond>(); this.searchconds = new ArrayList<ISearchCond>();
} }
return this.searchconds; return this.searchconds;
...@@ -195,36 +194,36 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -195,36 +194,36 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
SearchFieldCond searchFieldCond = new SearchFieldCond(); SearchFieldCond searchFieldCond = new SearchFieldCond();
searchFieldCond.setFieldName(strFieldName); searchFieldCond.setFieldName(strFieldName);
searchFieldCond.setCondOp(strCondOp); searchFieldCond.setCondOp(strCondOp);
if(Conditions.ISNULL.equals(strCondOp) if (Conditions.ISNULL.equals(strCondOp)
|| Conditions.ISNOTNULL.equals(strCondOp)) { || Conditions.ISNOTNULL.equals(strCondOp)) {
objValue="1"; objValue = "1";
} }
searchFieldCond.setParamMode(true); searchFieldCond.setParamMode(true);
String strParamName = String.format("n_%1$s_%2$s", strFieldName, strCondOp).toLowerCase(); String strParamName = String.format("n_%1$s_%2$s", strFieldName, strCondOp).toLowerCase();
if(!hasFieldCond(strParamName)) { if (!hasFieldCond(strParamName)) {
searchFieldCond.setValue(strParamName); searchFieldCond.setValue(strParamName);
this.getParamMap().put(strParamName, objValue); this.getParamMap().put(strParamName, objValue);
this.getSearchCondsIf().add(searchFieldCond); this.getSearchCondsIf().add(searchFieldCond);
} }
String fieldRealName = FieldCache.getFieldRealName(BaseFilter.class, strParamName); FieldCache.FieldItem filedItem = FieldCache.getField(this.getClass(),strParamName);
if (StringUtils.isEmpty(fieldRealName) && (!this.getClass().isAssignableFrom(BaseFilter.class))) { if (filedItem!=null) {
fieldRealName = FieldCache.getFieldRealName(this.getClass(), strParamName);
}
if (!StringUtils.isEmpty(fieldRealName)) {
try { try {
Field field = this.getClass().getDeclaredField(fieldRealName); Field field = filedItem.getField();
field.setAccessible(true); field.setAccessible(true);
if (objValue instanceof Collection) { if (objValue instanceof Collection) {
Collection collection = (Collection) objValue; Collection collection = (Collection) objValue;
Object joinObject = collection.stream().collect(Collectors.joining(",")); Object joinObject = collection.stream().collect(Collectors.joining(","));
field.set(this, joinObject != null ? String.valueOf(joinObject) : joinObject); field.set(this, joinObject != null ? String.valueOf(joinObject) : joinObject);
}else { } else if (objValue instanceof String[]) {
String[] array = (String[]) objValue;
Collection collection = Arrays.asList(array);
Object joinObject = collection.stream().collect(Collectors.joining(","));
field.set(this, joinObject != null ? String.valueOf(joinObject) : joinObject);
} else {
field.set(this, objValue); field.set(this, objValue);
} }
} catch (NoSuchFieldException e) {
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
} }
...@@ -234,11 +233,12 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -234,11 +233,12 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
} }
public boolean hasFieldCond(String fieldCondName) { public boolean hasFieldCond(String fieldCondName) {
return this.getSearchCondsIf().stream().filter(f->f instanceof SearchFieldCond && fieldCondName.equals(((SearchFieldCond) f).getValue())).count()>0; return this.getSearchCondsIf().stream().filter(f -> f instanceof SearchFieldCond && fieldCondName.equals(((SearchFieldCond) f).getValue())).count() > 0;
} }
/** /**
* 指定属性值等于条件值 * 指定属性值等于条件值
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -249,6 +249,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -249,6 +249,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值不等于条件值 * 指定属性值不等于条件值
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -259,6 +260,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -259,6 +260,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值大于条件值 * 指定属性值大于条件值
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -269,6 +271,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -269,6 +271,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值大于等于条件值 * 指定属性值大于等于条件值
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -279,6 +282,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -279,6 +282,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值小于条件值 * 指定属性值小于条件值
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -289,6 +293,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -289,6 +293,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值小于等于条件值 * 指定属性值小于等于条件值
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -299,6 +304,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -299,6 +304,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值匹配条件值 * 指定属性值匹配条件值
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -309,6 +315,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -309,6 +315,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值左侧匹配条件值 * 指定属性值左侧匹配条件值
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -319,6 +326,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -319,6 +326,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值右侧匹配条件值 * 指定属性值右侧匹配条件值
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -329,6 +337,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -329,6 +337,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值为空 * 指定属性值为空
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -339,6 +348,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -339,6 +348,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值不为空 * 指定属性值不为空
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -349,6 +359,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -349,6 +359,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值在值范围中 * 指定属性值在值范围中
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -359,6 +370,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -359,6 +370,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 指定属性值不在值范围中 * 指定属性值不在值范围中
*
* @param strFieldName * @param strFieldName
*/ */
@Override @Override
...@@ -369,6 +381,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -369,6 +381,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 添加自定义条件 * 添加自定义条件
*
* @param strCustomCond * @param strCustomCond
*/ */
@Override @Override
...@@ -392,7 +405,6 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -392,7 +405,6 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
} }
@Override @Override
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
...@@ -446,6 +458,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -446,6 +458,7 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
/** /**
* 设置直接变量值 * 设置直接变量值
*
* @param strName * @param strName
* @param objValue * @param objValue
* @return * @return
...@@ -496,8 +509,8 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -496,8 +509,8 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
@JSONField(serialize = false) @JSONField(serialize = false)
public String getDrillDownCond() { public String getDrillDownCond() {
Object drilldowncond = this.get(PARAM_DRILLDOWNCOND); Object drilldowncond = this.get(PARAM_DRILLDOWNCOND);
if(drilldowncond instanceof String) { if (drilldowncond instanceof String) {
return (String)drilldowncond; return (String) drilldowncond;
} }
return null; return null;
} }
...@@ -508,30 +521,33 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -508,30 +521,33 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
@JSONField(serialize = false) @JSONField(serialize = false)
public String getGroupCond() { public String getGroupCond() {
Object groupcond = this.get(PARAM_GROUPCOND); Object groupcond = this.get(PARAM_GROUPCOND);
if(groupcond instanceof String) { if (groupcond instanceof String) {
return (String)groupcond; return (String) groupcond;
} }
return null; return null;
} }
public void setCount(boolean count) public void setCount(boolean count) {
{ this.setObject("count", count);
this.setObject("count",count);
} }
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
public boolean getCount(){return this.getBoolean("count",true).booleanValue();} public boolean getCount() {
return this.getBoolean("count", true).booleanValue();
}
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
public boolean isCount(){return this.getBoolean("count",true).booleanValue();} public boolean isCount() {
return this.getBoolean("count", true).booleanValue();
}
@Override @Override
public BaseFilter count(boolean bCount) { public BaseFilter count(boolean bCount) {
this.setObject("count",bCount); this.setObject("count", bCount);
return this; return this;
} }
...@@ -540,13 +556,15 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -540,13 +556,15 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
public Long offset = 0L; public Long offset = 0L;
public String sort; public String sort;
public void setSort(String sort) { public void setSort(String sort) {
if (sort !=null) { if (sort != null) {
sort = sort.trim(); sort = sort.trim();
this.setPageSort(sort); this.setPageSort(sort);
} }
this.sort=sort; this.sort = sort;
} }
@Override @Override
public BaseFilter sort(String strSortInfo) { public BaseFilter sort(String strSortInfo) {
this.setSort(strSortInfo); this.setSort(strSortInfo);
...@@ -556,12 +574,13 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -556,12 +574,13 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
private Sort pageSort = null; private Sort pageSort = null;
public void setPageSort(String strSortInfo) { public void setPageSort(String strSortInfo) {
Sort pageSort = null; Sort pageSort = null;
if (StringUtils.hasLength(strSortInfo)) { if (StringUtils.hasLength(strSortInfo)) {
List<Sort.Order> list = new ArrayList<Sort.Order>(); List<Sort.Order> list = new ArrayList<Sort.Order>();
String[] parts = strSortInfo.split("[;]"); String[] parts = strSortInfo.split("[;]");
for(String strPart : parts) { for (String strPart : parts) {
String[] items = strPart.split("[,]"); String[] items = strPart.split("[,]");
if (items.length == 1) { if (items.length == 1) {
list.add(Sort.Order.asc(items[0])); list.add(Sort.Order.asc(items[0]));
...@@ -577,8 +596,8 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -577,8 +596,8 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
pageSort = Sort.by(list); pageSort = Sort.by(list);
} }
} }
this.sort=strSortInfo; this.sort = strSortInfo;
this.pageSort=pageSort; this.pageSort = pageSort;
} }
@Override @Override
...@@ -603,26 +622,25 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -603,26 +622,25 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
@Override @Override
public void setPageSort(Sort pageSort) { public void setPageSort(Sort pageSort) {
String strSortInfo=null; String strSortInfo = null;
if(pageSort != null && pageSort != Sort.unsorted()) { if (pageSort != null && pageSort != Sort.unsorted()) {
java.util.Iterator<Sort.Order> orders = pageSort.iterator(); java.util.Iterator<Sort.Order> orders = pageSort.iterator();
if(orders != null) { if (orders != null) {
List<String> sortInfos = new ArrayList<>(); List<String> sortInfos = new ArrayList<>();
while (orders.hasNext()) { while (orders.hasNext()) {
Sort.Order order = orders.next(); Sort.Order order = orders.next();
if(order.isAscending()) { if (order.isAscending()) {
sortInfos.add(String.format("%1$s,asc", order.getProperty())); sortInfos.add(String.format("%1$s,asc", order.getProperty()));
} } else {
else {
sortInfos.add(String.format("%1$s,desc", order.getProperty())); sortInfos.add(String.format("%1$s,desc", order.getProperty()));
} }
} }
if(sortInfos.size()>0) if (sortInfos.size() > 0)
strSortInfo=String.join(";",sortInfos); strSortInfo = String.join(";", sortInfos);
} }
} }
this.sort=strSortInfo; this.sort = strSortInfo;
this.pageSort=pageSort; this.pageSort = pageSort;
} }
@Override @Override
...@@ -649,27 +667,27 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -649,27 +667,27 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
private Pageable pageable = null; private Pageable pageable = null;
public void setPageable(Pageable pageable){
this.page=pageable.getPageNumber(); public void setPageable(Pageable pageable) {
this.size=pageable.getPageSize(); this.page = pageable.getPageNumber();
this.offset=pageable.getOffset(); this.size = pageable.getPageSize();
this.pageable=pageable; this.offset = pageable.getOffset();
this.pageable = pageable;
} }
public void setPageable(int nPageNumber, int nPageSize, long nOffset) { public void setPageable(int nPageNumber, int nPageSize, long nOffset) {
this.setPageable(PageRequest.of(nPageNumber, nPageSize, nOffset)); this.setPageable(PageRequest.of(nPageNumber, nPageSize, nOffset));
} }
public Pageable getPageable() { public Pageable getPageable() {
if(pageable==null) { if (pageable == null) {
pageable=PageRequest.of(page, size, offset); pageable = PageRequest.of(page, size, offset);
} }
return pageable; return pageable;
} }
public Object get(String strName) {
public Object get(String strName){
return getObject(strName); return getObject(strName);
} }
...@@ -682,103 +700,94 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -682,103 +700,94 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
@Transient @Transient
private BeanMap getMap() private BeanMap getMap() {
{ if (map == null) {
if(map==null) { map = BeanMap.create(this);
map=BeanMap.create(this);
} }
return map; return map;
} }
public Object getObject(String strName) public Object getObject(String strName) {
{ String fieldRealName = FieldCache.getFieldRealName(BaseFilter.class, strName);
String fieldRealName= FieldCache.getFieldRealName(BaseFilter.class,strName); if (StringUtils.isEmpty(fieldRealName) && (!this.getClass().isAssignableFrom(BaseFilter.class))) {
if(StringUtils.isEmpty(fieldRealName)&&(!this.getClass().isAssignableFrom(BaseFilter.class))) { fieldRealName = FieldCache.getFieldRealName(this.getClass(), strName);
fieldRealName=FieldCache.getFieldRealName(this.getClass(),strName);
} }
if(!StringUtils.isEmpty(fieldRealName)) { if (!StringUtils.isEmpty(fieldRealName)) {
return getMap().get(fieldRealName); return getMap().get(fieldRealName);
} } else {
else {
return this.getParamMap().get(strName); return this.getParamMap().get(strName);
} }
} }
public QueryWrapper<T> getSearchCond(boolean gen) public QueryWrapper<T> getSearchCond(boolean gen) {
{
return QueryHelper.getQueryWrapper(this); return QueryHelper.getQueryWrapper(this);
} }
public void modify(String field,Object val) { public void modify(String field, Object val) {
} }
public void set(String field, String value) { public void set(String field, String value) {
setObject(field,value); setObject(field, value);
} }
public void set(String field, Object value) { public void set(String field, Object value) {
setObject(field,value); setObject(field, value);
} }
@JsonAnySetter @JsonAnySetter
@JSONField(name = "_any", unwrapped = true, serialize = false, deserialize = true) @JSONField(name = "_any", unwrapped = true, serialize = false, deserialize = true)
public void setObject(String field, Object value) { public void setObject(String field, Object value) {
try try {
{ switch (field.toLowerCase()) {
switch (field.toLowerCase())
{
case "size": case "size":
this.setSize(DataTypeUtils.getIntegerValue(value,20)); this.setSize(DataTypeUtils.getIntegerValue(value, 20));
break; break;
case "page": case "page":
this.setPage(DataTypeUtils.getIntegerValue(value,0)); this.setPage(DataTypeUtils.getIntegerValue(value, 0));
break; break;
case "offset": case "offset":
this.setOffset(DataTypeUtils.getLongValue(value,0L)); this.setOffset(DataTypeUtils.getLongValue(value, 0L));
break; break;
case "searchconds": case "searchconds":
if((!ObjectUtils.isEmpty(value))&&(value instanceof List)) if ((!ObjectUtils.isEmpty(value)) && (value instanceof List))
this.setSearchconds((List)value); this.setSearchconds((List) value);
break; break;
case "query": case "query":
this.setQuery(DataTypeUtils.getStringValue(value,null)); this.setQuery(DataTypeUtils.getStringValue(value, null));
break; break;
case "pageable": case "pageable":
if(value instanceof Pageable) if (value instanceof Pageable)
this.setPageable((Pageable)value); this.setPageable((Pageable) value);
case "pagesort": case "pagesort":
if(value instanceof Sort) if (value instanceof Sort)
this.setPageSort((Sort)value); this.setPageSort((Sort) value);
else else
this.setPageSort(DataTypeUtils.getStringValue(value,null)); this.setPageSort(DataTypeUtils.getStringValue(value, null));
break; break;
case "sort": case "sort":
this.setSort(DataTypeUtils.getStringValue(value,null)); this.setSort(DataTypeUtils.getStringValue(value, null));
break; break;
case "idefilterdtoruntime": case "idefilterdtoruntime":
if(value instanceof IDEFilterDTORuntime) if (value instanceof IDEFilterDTORuntime)
this.setIDEFilterDTORuntime((IDEFilterDTORuntime)value); this.setIDEFilterDTORuntime((IDEFilterDTORuntime) value);
break; break;
default: default:
String fieldRealName= FieldCache.getFieldRealName(this.getClass(),field); String fieldRealName = FieldCache.getFieldRealName(this.getClass(), field);
if(!StringUtils.isEmpty(fieldRealName)) { if (!StringUtils.isEmpty(fieldRealName)) {
if (value == null) { if (value == null) {
getMap().put(fieldRealName, null); getMap().put(fieldRealName, null);
} } else {
else {
getMap().put(fieldRealName, FieldCache.fieldValueOf(this.getClass(), fieldRealName, value)); getMap().put(fieldRealName, FieldCache.fieldValueOf(this.getClass(), fieldRealName, value));
} }
} else {
this.getParamMap().put(field, value);
} }
else {
this.getParamMap().put(field,value);
} }
} catch (Exception ex) {
} }
}catch (Exception ex){}
} }
...@@ -787,14 +796,14 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO { ...@@ -787,14 +796,14 @@ public class BaseFilter<T> extends BaseData implements ISearchContextDTO {
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
public void resetAll() { public void resetAll() {
getMap().keySet().forEach(key->{ getMap().keySet().forEach(key -> {
if((!key.toString().equalsIgnoreCase("dataSet"))&&(!key.toString().toLowerCase().endsWith("defilterdtoruntime"))) if ((!key.toString().equalsIgnoreCase("dataSet")) && (!key.toString().toLowerCase().endsWith("defilterdtoruntime")))
map.put(key,null); map.put(key, null);
}); });
super.resetAll(); super.resetAll();
page=0; page = 0;
size=20; size = 20;
offset=0L; offset = 0L;
} }
public String getCat() { public String getCat() {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册