您的位置:首页 > 其它

根据pid递归list的方法

2017-10-11 14:33 162 查看
后台项目递归

@Override
public List<SxZlNode> getAllSxZlNodeListByCondition() {
SxZlNode node = new SxZlNode();
node.setNodeId(null);
List<SxZlNode> nodeList = sxZlNodeMapper.selectNodeListByPid(node);
if (nodeList != null && nodeList.size() > 0) {
return findAllNodeList(nodeList);
} else {
return null;
}
}

// 递归获取所有节点及图片集合
private List<SxZlNode> findAllNodeList(List<SxZlNode> sxZlNodeList) {
for (SxZlNode node : sxZlNodeList) {
List<SxZlNode> nodeList = sxZlNodeMapper.selectNodeListByPid(node);
if (nodeList != null && nodeList.size() > 0) {
node.setSxZlNodeList(findAllNodeList(nodeList));
} else {
SxZlPicture sxZlPicture = new SxZlPicture();
sxZlPicture.setNodeId(node.getNodeId());
List<SxZlPicture> pictureList = sxZlPictureMapper.selectPictureListByNodeId(sxZlPicture);
if (pictureList != null && pictureList.size() > 0) {
node.setSxZlPictureList(pictureList);
}
}
}
return sxZlNodeList;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐