Commit 43e34a4b by wenyang

标签场景查询根据 DisplayOrder降序排序

parent 6b94438c
package com.yd.api.metadata.service.impl; package com.yd.api.metadata.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -316,12 +317,42 @@ public class MetadataServiceImpl implements MetadataService { ...@@ -316,12 +317,42 @@ public class MetadataServiceImpl implements MetadataService {
tagViewQueryInfos.add(tagViewQueryInfo); tagViewQueryInfos.add(tagViewQueryInfo);
} }
} }
//降序排序
tagViewQueryOrderByDisplay(tagViewQueryInfos);
responseVO.setTagViewQueryInfos(tagViewQueryInfos); responseVO.setTagViewQueryInfos(tagViewQueryInfos);
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000"))); responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
return responseVO; return responseVO;
} }
/**
* 返回的标签根据 DisplayOrder降序排序
* @param tagViewQueryInfos
*/
private void tagViewQueryOrderByDisplay(List<TagViewQueryInfo> tagViewQueryInfos){
if(tagViewQueryInfos != null && tagViewQueryInfos.size() > 0){
tagViewQueryInfos.sort(new Comparator<TagViewQueryInfo>() {
@Override
public int compare(TagViewQueryInfo o1, TagViewQueryInfo o2) {
if(o2.getDisplayOrder() == null){
o2.setDisplayOrder(-1);
}
if(o1.getDisplayOrder() == null){
o1.setDisplayOrder(-1);
}
//按照value值,用compareTo()方法默认是从小到大排序
return o2.getDisplayOrder().compareTo(o1.getDisplayOrder());
}
});
for (TagViewQueryInfo tagViewQueryInfo : tagViewQueryInfos) {
if(tagViewQueryInfo != null && tagViewQueryInfo.getTagViewQueryInfos() != null && tagViewQueryInfo.getTagViewQueryInfos().size() > 0){
tagViewQueryOrderByDisplay(tagViewQueryInfo.getTagViewQueryInfos());
}
}
}
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void classificationBuildUpMdTagView(List<MdTagView> mdTagViewList, private void classificationBuildUpMdTagView(List<MdTagView> mdTagViewList,
List<MdTagView> mdTagViewAddList, List<MdTagView> mdTagViewAddList,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment