根据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;
}
@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;
}
相关文章推荐
- 根据前序跟中序遍历的结果建立二叉树——迭代和递归的方法
- List<T>泛型数组API自带的Sort() 排序方法根据自定义排序实现
- 2015061502 - List中根据某个字段进行排序(方法1)
- 对指定文件夹进行递归遍历,将所有文件存到QStringList里。两种方法
- 根据GUID和PID和USB设备通信的方法
- <转>根据泛型生成数组 与数组 List相互转换的方法
- 自己写的一个根据结点名称查找CTreeCtrl树中对应结点的方法(用的是递归思想)
- C# List根据值找到索引值方法
- 根据List中单个对象的某方法进行去重
- 用Collections.sort方法对list排序有两种方法 第一种是list中的对象实现Comparable接口,如下: [java] view plain copy /** * 根据ord
- 自己写的一个根据结点名称查找CTreeCtrl树中对应结点的方法(用的是递归思想)
- 根据List的对象的某个属性进行排序方法
- Windows中根据端口号或PID查看进程、结束进程方法
- Python多层嵌套list的递归处理方法(推荐)
- 根据前序和中序数组构造二叉树(递归方法)
- java根据List内对象的属性排序方法
- level-list根据setimagelevel和setlevel方法中给的int显示图片;和selector类似
- mysql使用递归,根据pId,循环查询所有子类
- 根据部分属性判断List<实体bean>中是否含有某个实体bean-重写equals方法
- 分享一个递归无限级拼接Json的方法---ExtJs的TreePanel和TreeGrid均适用(Ef,Lambda,Linq,IQueryable,List)