原创

Java-获取当前节点下的所有关联子节点id(无限下级)

//获取当前节点下的所有关联子节点id(无限下级)
private void addAllChildIdList(Integer currentANode, List<Integer> allNeedAdd1LevelChildList) {
List<EduTrainCategory> childNodeList = eduTrainCategoryMapper.selectChildCategoryByParentId(currentANode);
if (!CollectionUtils.isEmpty(childNodeList)) {
for (EduTrainCategory childNode : childNodeList) {
Integer id = childNode.getId();
allNeedAdd1LevelChildList.add(id);
//注意这里不用return
addAllChildIdList(id, allNeedAdd1LevelChildList);
}
}
}
正文到此结束
本文目录