原 java 递归
版权声明:本文为博主原创文章,请尊重他人的劳动成果,转载请附上原文出处链接和本声明。
本文链接:https://www.91mszl.com/Dream/article/details/1469
public List<H5ConfigVO> getNodes(String orgId, List<H5ConfigVO> orgList) {
List<H5ConfigVO> dataList=new ArrayList<>();
for(H5ConfigVO ho : orgList){
if(ho.getSuperDataCode().equals(orgId)){
ho.setChildrensList(getNodes(ho.getDataCode(), orgList));
dataList.add(ho);
}
}
return dataList;
}
public List<H5ConfigVO> getChildrens(String orgId, List<H5ConfigVO> orgList) {
List<H5ConfigVO> childrenList=orgList.stream().filter(item -> {
return StringUtils.isNotBlank(item.getSuperDataCode()) && item.getSuperDataCode().equals(orgId);
}).map(item -> {
item.setChildrensList(getChildrens(item.getDataCode(), orgList));
return item;
}).collect(Collectors.toList());
return childrenList;
}
实体
package com.mszl.model.vo;
import lombok.Data;
import java.util.List;
@Data
public class H5ConfigVO {
private String dataCode;
private String superDataCode;
private List<H5ConfigVO> childrensList;
}
2024-01-30 09:28:12 阅读(226)
名师出品,必属精品 https://www.91mszl.com
博主信息