当前位置:网站首页>获取树形菜单列表

获取树形菜单列表

2020-11-07 21:03:12 麦漁翁

获取树形菜单列表

/**
 * 获取区域树形列表
 * @return
 */
public List<MapAreaTreeVo> getAreaTreeList(){
	List<MapAreaTreeVo> arealist = areaDao.getAreaTreeList(0);
	for(MapAreaTreeVo vo :arealist){
	//递归循环获取
		vo.setChildren(getAreaTreePidList(vo.getId()));
	}
	return arealist;
}

/**
 * 获取父菜单下的树形列表
 * @param pid
 * @return
 */
public List<MapAreaTreeVo> getAreaTreePidList(Integer pid){
	List<MapAreaTreeVo> mapAreaTreeVoList = areaDao.getAreaTreeList(pid);
	if(null!=mapAreaTreeVoList && mapAreaTreeVoList.size()>0){
		for(MapAreaTreeVo vo:mapAreaTreeVoList){
				vo.setChildren(getAreaTreePidList(vo.getId()));
		}
	}
	return mapAreaTreeVoList;
}

实体类

public class MapAreaTreeVo {
    private Integer id;
    private Integer pid;
    private String title;
    private List<MapAreaTreeVo> children;
}

版权声明
本文为[麦漁翁]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/3204029/blog/4707687