根据pid递归list的方法

来源:互联网 发布:机加工编程软件 编辑:程序博客网 时间:2024/06/15 07:11


后台项目递归


@Overridepublic 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;}