课程敏感词审核修正

This commit is contained in:
2026-01-14 12:24:47 +08:00
parent 6b43285b9c
commit 912e8e01bf

View File

@@ -126,17 +126,23 @@ public class SCCourseServiceImpl implements SCCourseService {
// 查询所有节点 // 查询所有节点
List<TbCourseNode> nodes = courseNodeMapper.selectCourseNodesByChapterIDs(chapterIDs); List<TbCourseNode> nodes = courseNodeMapper.selectCourseNodesByChapterIDs(chapterIDs);
// 转换章节为CourseItemVO列表
List<CourseItemVO> chapterVOs = chapters.stream()
.map(CourseItemVO::fromChapter)
.collect(Collectors.toList());
// 转换节点为CourseItemVO并按章节ID分组 // 转换节点为CourseItemVO并按章节ID分组
Map<String, List<CourseItemVO>> nodesMap = nodes.stream() Map<String, List<CourseItemVO>> nodesMap = nodes.stream()
.map(CourseItemVO::fromNode) .map(CourseItemVO::fromNode)
.collect(Collectors.groupingBy(CourseItemVO::getChapterID)); .collect(Collectors.groupingBy(CourseItemVO::getChapterID));
// 设置章节列表和章节节点映射 // 转换章节为CourseItemVO列表并将节点嵌入到章节的chapters字段中
List<CourseItemVO> chapterVOs = chapters.stream()
.map(chapter -> {
CourseItemVO chapterVO = CourseItemVO.fromChapter(chapter);
// 将该章节的节点设置到chapters字段中前端编辑组件使用这个结构
List<CourseItemVO> chapterNodes = nodesMap.getOrDefault(chapter.getChapterID(), new ArrayList<>());
chapterVO.setChapters(chapterNodes);
return chapterVO;
})
.collect(Collectors.toList());
// 设置章节列表和章节节点映射保留chapterNodes用于其他场景
courseItemVO.setChapters(chapterVOs); courseItemVO.setChapters(chapterVOs);
courseItemVO.setChapterNodes(nodesMap); courseItemVO.setChapterNodes(nodesMap);
} }
@@ -525,37 +531,57 @@ public class SCCourseServiceImpl implements SCCourseService {
courseMapper.updateCourse(course2); courseMapper.updateCourse(course2);
// 敏感词审核 // 敏感词审核
// nodeType: 0=文章资源, 1=富文本, 2=上传文件
List<TbCourseNode> notPassList = new ArrayList<>(); List<TbCourseNode> notPassList = new ArrayList<>();
for(TbCourseNode node: nodeList){ for(TbCourseNode node: nodeList){
if(!node.getIsAudited()){ if(!node.getIsAudited()){
// 重新审核 // 重新审核
int type = node.getNodeType(); int type = node.getNodeType();
// auditService.
if(type==1){ //文章类型
ResultDomain<ResourceVO> resourceDomain = resourceService.getResourceById(node.getResourceID());
if (resourceDomain.isSuccess()) {
if (!resourceDomain.getData().getResource().getIsAudited()) {
ResultDomain<String> pass = auditService.auditText(resourceDomain.getData().getResource().getTitle()+" "+resourceDomain.getData().getResource().getContent());
if(!pass.isSuccess()){
// 审核失败标记课程状态为4审核失败
course.setStatus(4);
course.setUpdateTime(new Date());
courseMapper.updateCourse(course);
auditService.sendAuditResultMessage(node.getCreator(), "课程节点:"+node.getName(), pass.getDataList());
resultDomain.fail("课程节点:"+node.getName()+"审核未通过"); if(type == 0){ // 文章资源类型
return resultDomain; if (node.getResourceID() != null && !node.getResourceID().trim().isEmpty()) {
}else{ ResultDomain<ResourceVO> resourceDomain = resourceService.getResourceById(node.getResourceID());
// 更新文章的审核状态 if (resourceDomain.isSuccess()) {
ResourceVO resource = new ResourceVO(); if (!resourceDomain.getData().getResource().getIsAudited()) {
resource.setResource(new TbResource()); ResultDomain<String> pass = auditService.auditText(resourceDomain.getData().getResource().getTitle()+" "+resourceDomain.getData().getResource().getContent());
resource.getResource().setResourceID(node.getResourceID()); if(!pass.isSuccess()){
resource.getResource().setIsAudited(true); // 审核失败标记课程状态为4审核失败
resourceService.updateResource(resource); course.setStatus(4);
course.setUpdateTime(new Date());
courseMapper.updateCourse(course);
auditService.sendAuditResultMessage(node.getCreator(), "课程节点:"+node.getName(), pass.getDataList());
resultDomain.fail("课程节点:"+node.getName()+"审核未通过");
return resultDomain;
}else{
// 更新文章的审核状态
ResourceVO resource = new ResourceVO();
resource.setResource(new TbResource());
resource.getResource().setResourceID(node.getResourceID());
resource.getResource().setIsAudited(true);
resourceService.updateResource(resource);
}
} }
} }
} }
}else if (type == 2){ } else if(type == 1){ // 富文本类型
if (node.getContent() != null && !node.getContent().trim().isEmpty()) {
ResultDomain<String> pass = auditService.auditText(node.getName() + " " + node.getContent());
if(!pass.isSuccess()){
// 审核失败标记课程状态为4审核失败
course.setStatus(4);
course.setUpdateTime(new Date());
courseMapper.updateCourse(course);
auditService.sendAuditResultMessage(node.getCreator(), "课程节点:"+node.getName(), pass.getDataList());
resultDomain.fail("课程节点:"+node.getName()+"审核未通过");
return resultDomain;
} else {
// 更新node审核状态
node.setIsAudited(true);
courseNodeMapper.updateCourseNode(node);
}
}
} else if (type == 2){ // 上传文件类型
ResultDomain<String> pass = auditService.auditByFileId(node.getResourceID()); ResultDomain<String> pass = auditService.auditByFileId(node.getResourceID());
if(!pass.isSuccess()){ if(!pass.isSuccess()){
// 审核失败标记课程状态为4审核失败 // 审核失败标记课程状态为4审核失败
@@ -566,22 +592,6 @@ public class SCCourseServiceImpl implements SCCourseService {
resultDomain.fail("课程节点:"+node.getName()+"审核未通过"); resultDomain.fail("课程节点:"+node.getName()+"审核未通过");
return resultDomain; return resultDomain;
} }
}else{
ResultDomain<String> pass = auditService.auditText(node.getContent());
if(!pass.isSuccess()){
// 审核失败标记课程状态为3审核失败
course.setStatus(3);
course.setUpdateTime(new Date());
courseMapper.updateCourse(course);
auditService.sendAuditResultMessage(node.getCreator(), "课程节点:"+node.getName(), pass.getDataList());
resultDomain.fail("课程节点:"+node.getName()+"审核未通过");
return resultDomain;
}else{
// 更新node审核状态
node.setIsAudited(true);
courseNodeMapper.updateCourseNode(node);
}
} }
node.setIsAudited(true); node.setIsAudited(true);
notPassList.add(node); notPassList.add(node);