/**标签:java,树状,list,inBean,Long,获取,outBean,returnList From: https://www.cnblogs.com/xianz666/p/18166573
* 转成树状结构
*/
public List<DictVO> toTree(List<DictVO> list){
List<DictVO>treelist=new ArrayList<DictVO>();
for(DictVO outBean:list) {
for(DictVO inBean:list) {
Long outid=outBean.getId();
Long inpid=inBean.getParentId();
if(outid.equals(inpid)) {
List<DictVO>maplist=(ArrayList) outBean.getChildren();
maplist.add(inBean);
}
}
Long prid=outBean.getParentId();
if(!Func.isEmpty(prid)) {
treelist.add(outBean);
}
}
return treelist;
}
/**
* 递归获取所有子集
*/
/**
*递归获取树状结构子集
* @param list
* @param returnList
* @return
*/
public List<DictVO>getList(List<DictVO>list,List<DictVO>returnList){
if(Func.isNotEmpty(list)){
for(DictVO bean:list){
List<DictVO>list1=baseMapper.getListByParentId(bean.getId());
returnList.add(bean);
if(Func.isNotEmpty(list1)){
getList(list1,returnList);
}
}
}
return returnList;
}