diff --git a/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java index 26c8c5c..b9abb53 100644 --- a/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java @@ -154,10 +154,10 @@ public class ChapterServiceImpl extends ServiceImpl impl @Override public List getChapterTree(String courseId) { - System.out.println(courseId); + List chapters=baseMapper.selectSectionsByCourseId(courseId); - System.out.println(chapters); + Map chapterMap=new HashMap<>(); List roots=new ArrayList<>(); @@ -167,13 +167,11 @@ public class ChapterServiceImpl extends ServiceImpl impl chapter.setChildren(new ArrayList<>()); chapterMap.put(chapter.getId(),chapter); - } - System.out.println(chapterMap); - for (Chapter chapter:chapters){ String parentId=chapter.getPid(); - if (parentId!=null){ + + if (!parentId.equals("0")){ Chapter parentChapter=chapterMap.get(parentId); if (parentChapter != null) { parentChapter.getChildren().add(chapter); @@ -183,7 +181,7 @@ public class ChapterServiceImpl extends ServiceImpl impl roots.add(chapter); } } - System.out.println(roots); + return roots; }