From 6b43285b9c058ee53a28fe00f043501034fff810 Mon Sep 17 00:00:00 2001 From: wangys <3401275564@qq.com> Date: Wed, 14 Jan 2026 11:53:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=91=E5=B8=83=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SCCourseServiceImpl.java | 109 +++++++----------- 1 file changed, 41 insertions(+), 68 deletions(-) diff --git a/schoolNewsServ/study/src/main/java/org/xyzh/study/service/impl/SCCourseServiceImpl.java b/schoolNewsServ/study/src/main/java/org/xyzh/study/service/impl/SCCourseServiceImpl.java index c7483c2..d8972ee 100644 --- a/schoolNewsServ/study/src/main/java/org/xyzh/study/service/impl/SCCourseServiceImpl.java +++ b/schoolNewsServ/study/src/main/java/org/xyzh/study/service/impl/SCCourseServiceImpl.java @@ -154,72 +154,6 @@ public class SCCourseServiceImpl implements SCCourseService { return resultDomain; } - // 验证课程基本信息 - if (courseItemVO.getName() == null || courseItemVO.getName().trim().isEmpty()) { - resultDomain.fail("课程名称不能为空"); - return resultDomain; - } - - // 验证章节 - List chapterVOs = courseItemVO.getChapters(); - if (chapterVOs == null || chapterVOs.isEmpty()) { - resultDomain.fail("课程至少需要一个章节"); - return resultDomain; - } - - // 验证每个章节 - for (int i = 0; i < chapterVOs.size(); i++) { - CourseItemVO chapterVO = chapterVOs.get(i); - if (chapterVO.getName() == null || chapterVO.getName().trim().isEmpty()) { - resultDomain.fail("第" + (i + 1) + "个章节名称不能为空"); - return resultDomain; - } - - // 验证章节节点 - List nodeVOs = chapterVO.getChapters(); - if (nodeVOs == null || nodeVOs.isEmpty()) { - resultDomain.fail("章节「" + chapterVO.getName() + "」至少需要一个学习节点"); - return resultDomain; - } - - // 验证每个节点 - for (int j = 0; j < nodeVOs.size(); j++) { - CourseItemVO nodeVO = nodeVOs.get(j); - if (nodeVO.getName() == null || nodeVO.getName().trim().isEmpty()) { - resultDomain.fail("章节「" + chapterVO.getName() + "」的第" + (j + 1) + "个节点名称不能为空"); - return resultDomain; - } - - // 根据节点类型验证内容 - Integer nodeType = nodeVO.getNodeType(); - if (nodeType == null) { - resultDomain.fail("章节「" + chapterVO.getName() + "」的节点「" + nodeVO.getName() + "」类型不能为空"); - return resultDomain; - } - - // 类型1:文章,需要resourceID - // 类型2:文件/视频,需要resourceID或videoUrl - // 类型3:文本,需要content - if (nodeType == 1) { - if (nodeVO.getResourceID() == null || nodeVO.getResourceID().trim().isEmpty()) { - resultDomain.fail("章节「" + chapterVO.getName() + "」的节点「" + nodeVO.getName() + "」需要关联文章"); - return resultDomain; - } - } else if (nodeType == 2) { - if ((nodeVO.getResourceID() == null || nodeVO.getResourceID().trim().isEmpty()) - && (nodeVO.getVideoUrl() == null || nodeVO.getVideoUrl().trim().isEmpty())) { - resultDomain.fail("章节「" + chapterVO.getName() + "」的节点「" + nodeVO.getName() + "」需要上传文件或视频"); - return resultDomain; - } - } else if (nodeType == 3) { - if (nodeVO.getContent() == null || nodeVO.getContent().trim().isEmpty()) { - resultDomain.fail("章节「" + chapterVO.getName() + "」的节点「" + nodeVO.getName() + "」内容不能为空"); - return resultDomain; - } - } - } - } - // 转换为课程实体并保存 TbCourse course = courseItemVO.toCourse(); String courseID = IDUtils.generateID(); @@ -544,14 +478,53 @@ public class SCCourseServiceImpl implements SCCourseService { public ResultDomain updateCourseStatus(TbCourse course) { ResultDomain resultDomain = new ResultDomain<>(); if(course.getStatus()==1){ // 发布前审核 + // 获取课程信息 + TbCourse existingCourse = courseMapper.selectByCourseId(course.getCourseID()); + if (existingCourse == null) { + resultDomain.fail("课程不存在"); + return resultDomain; + } + + // 获取所有章节 + TbCourseChapter chapterFilter = new TbCourseChapter(); + chapterFilter.setCourseID(course.getCourseID()); + List chapters = courseChapterMapper.selectCourseChapters(chapterFilter); + + // 检查是否有章节 + if (chapters == null || chapters.isEmpty()) { + resultDomain.fail("课程至少需要一个章节才能发布"); + return resultDomain; + } + + // 获取所有课程节点 + List nodeList = courseNodeMapper.selectByCourseId(course.getCourseID()); + + // 检查是否有节点 + if (nodeList == null || nodeList.isEmpty()) { + resultDomain.fail("课程至少需要一个学习节点才能发布"); + return resultDomain; + } + + // 检查每个章节是否都有节点 + Map> nodesByChapter = nodeList.stream() + .collect(java.util.stream.Collectors.groupingBy(TbCourseNode::getChapterID)); + + for (TbCourseChapter chapter : chapters) { + List chapterNodes = nodesByChapter.get(chapter.getChapterID()); + if (chapterNodes == null || chapterNodes.isEmpty()) { + resultDomain.fail("章节「" + chapter.getName() + "」至少需要一个学习节点才能发布"); + return resultDomain; + } + } + // 更新为审核中 TbCourse course2 = new TbCourse(); course2.setCourseID(course.getCourseID()); course2.setStatus(3); course2.setUpdateTime(new Date()); courseMapper.updateCourse(course2); - // 获取所有课程节点 - List nodeList = courseNodeMapper.selectByCourseId(course.getCourseID()); + + // 敏感词审核 List notPassList = new ArrayList<>(); for(TbCourseNode node: nodeList){ if(!node.getIsAudited()){