修改发布校验
This commit is contained in:
@@ -154,72 +154,6 @@ public class SCCourseServiceImpl implements SCCourseService {
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
// 验证课程基本信息
|
||||
if (courseItemVO.getName() == null || courseItemVO.getName().trim().isEmpty()) {
|
||||
resultDomain.fail("课程名称不能为空");
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
// 验证章节
|
||||
List<CourseItemVO> 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<CourseItemVO> 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<TbCourse> updateCourseStatus(TbCourse course) {
|
||||
ResultDomain<TbCourse> 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<TbCourseChapter> chapters = courseChapterMapper.selectCourseChapters(chapterFilter);
|
||||
|
||||
// 检查是否有章节
|
||||
if (chapters == null || chapters.isEmpty()) {
|
||||
resultDomain.fail("课程至少需要一个章节才能发布");
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
// 获取所有课程节点
|
||||
List<TbCourseNode> nodeList = courseNodeMapper.selectByCourseId(course.getCourseID());
|
||||
|
||||
// 检查是否有节点
|
||||
if (nodeList == null || nodeList.isEmpty()) {
|
||||
resultDomain.fail("课程至少需要一个学习节点才能发布");
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
// 检查每个章节是否都有节点
|
||||
Map<String, List<TbCourseNode>> nodesByChapter = nodeList.stream()
|
||||
.collect(java.util.stream.Collectors.groupingBy(TbCourseNode::getChapterID));
|
||||
|
||||
for (TbCourseChapter chapter : chapters) {
|
||||
List<TbCourseNode> 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<TbCourseNode> nodeList = courseNodeMapper.selectByCourseId(course.getCourseID());
|
||||
|
||||
// 敏感词审核
|
||||
List<TbCourseNode> notPassList = new ArrayList<>();
|
||||
for(TbCourseNode node: nodeList){
|
||||
if(!node.getIsAudited()){
|
||||
|
||||
Reference in New Issue
Block a user