Commit 9884d93c authored by 廖旭伟's avatar 廖旭伟

修改站点树接口返回值结构,增加层级

parent 72cc6d70
...@@ -50,6 +50,8 @@ public class SiteTreeSelectVO implements Serializable { ...@@ -50,6 +50,8 @@ public class SiteTreeSelectVO implements Serializable {
* 图标 * 图标
*/ */
private String icon; private String icon;
/** 层级 */
private Integer level;
/** /**
* 子节点 * 子节点
......
...@@ -203,8 +203,9 @@ public class SstBasicController extends BaseCRUDJsonBodyMappingController<SstBas ...@@ -203,8 +203,9 @@ public class SstBasicController extends BaseCRUDJsonBodyMappingController<SstBas
rootNode.setIsLeaf(false); rootNode.setIsLeaf(false);
rootNode.setLatitude("30.595081"); rootNode.setLatitude("30.595081");
rootNode.setLongitude("104.062983"); rootNode.setLongitude("104.062983");
rootNode.setSiteCount(getChildrenCount(resultList)-1); rootNode.setSiteCount(getChildrenCount(resultList,2)-1);
rootNode.setChildren(resultList); rootNode.setChildren(resultList);
rootNode.setLevel(1);
List<SiteTreeSelectVO> dataList = new ArrayList<>(); List<SiteTreeSelectVO> dataList = new ArrayList<>();
dataList.add(rootNode); dataList.add(rootNode);
model.put("data", dataList); model.put("data", dataList);
...@@ -225,14 +226,15 @@ public class SstBasicController extends BaseCRUDJsonBodyMappingController<SstBas ...@@ -225,14 +226,15 @@ public class SstBasicController extends BaseCRUDJsonBodyMappingController<SstBas
return ret; return ret;
} }
private static Integer getChildrenCount(List<SiteTreeSelectVO> children){ private static Integer getChildrenCount(List<SiteTreeSelectVO> children,int initLevel){
if(CollectionUtils.isEmpty(children)) { if(CollectionUtils.isEmpty(children)) {
return 1; return 1;
}else { }else {
int size = 1; int size = 1;
for (SiteTreeSelectVO vo:children){ for (SiteTreeSelectVO vo:children){
int c = getChildrenCount(vo.getChildren()); int c = getChildrenCount(vo.getChildren(),initLevel+1);
vo.setSiteCount(c); vo.setSiteCount(c);
vo.setLevel(initLevel);
size += c; size += c;
} }
return size; return size;
......
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