From ee50cd831626083653f9eb80f1f17ae8610b5add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=90=8C=E6=96=B0?= <13658798+jjhyyds@user.noreply.gitee.com> Date: Thu, 25 Jul 2024 17:29:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/chapter/ChapterServiceImpl.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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; }