课程、文章审核
This commit is contained in:
@@ -22,6 +22,7 @@ import org.xyzh.common.vo.TaskItemVO;
|
||||
import org.xyzh.news.mapper.ResourceMapper;
|
||||
import org.xyzh.news.mapper.ResourceTagMapper;
|
||||
import org.xyzh.system.utils.LoginUtil;
|
||||
import org.xyzh.api.news.resource.ResourceAuditService;
|
||||
import org.xyzh.api.news.resource.ResourceService;
|
||||
import org.xyzh.api.system.permission.ResourcePermissionService;
|
||||
import org.xyzh.common.vo.UserDeptRoleVO;
|
||||
@@ -54,6 +55,9 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
@Autowired
|
||||
private ResourcePermissionService resourcePermissionService;
|
||||
|
||||
@Autowired
|
||||
private ResourceAuditService auditService;
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbResource> getResourceList(TbResource filter) {
|
||||
ResultDomain<TbResource> resultDomain = new ResultDomain<>();
|
||||
@@ -256,6 +260,9 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
if (resourceVO.getResource().getStatus() == null) {
|
||||
resourceVO.getResource().setStatus(0); // 默认草稿状态
|
||||
}
|
||||
if (resourceVO.getResource().getIsAudited() == null) {
|
||||
resourceVO.getResource().setIsAudited(false); // 默认草稿状态
|
||||
}
|
||||
if (resourceVO.getResource().getViewCount() == null) {
|
||||
resourceVO.getResource().setViewCount(0);
|
||||
}
|
||||
@@ -271,6 +278,14 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
if (resourceVO.getResource().getIsBanner() == null) {
|
||||
resourceVO.getResource().setIsBanner(false);
|
||||
}
|
||||
TbResource resource = resourceVO.getResource();
|
||||
if(resource.getStatus()==1 && !resource.getIsAudited()){
|
||||
// 进行审核
|
||||
ResultDomain<Boolean> pass =auditService.auditText(resource.getContent());
|
||||
if(pass.isSuccess() && pass.getData()){
|
||||
resource.setIsAudited(true);
|
||||
}
|
||||
}
|
||||
|
||||
// 插入数据库
|
||||
int result = resourceMapper.insertResource(resourceVO.getResource());
|
||||
@@ -345,14 +360,9 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
// 如果修改了标题,检查标题是否已被使用
|
||||
if (StringUtils.hasText(resource.getTitle()) && !resource.getTitle().equals(existing.getTitle())) {
|
||||
List<UserDeptRoleVO> userDeptRoles = LoginUtil.getCurrentDeptRole();
|
||||
int count = resourceMapper.countByTitle(resource.getTitle(), resource.getResourceID(), userDeptRoles);
|
||||
if (count > 0) {
|
||||
resultDomain.fail("资源标题已存在");
|
||||
return resultDomain;
|
||||
}
|
||||
resource.setIsAudited(existing.getIsAudited());
|
||||
if(!existing.getContent().equals(resource.getContent())){
|
||||
resource.setIsAudited(false);
|
||||
}
|
||||
Date now = new Date();
|
||||
// tag先删后增
|
||||
@@ -447,7 +457,20 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
resultDomain.fail("资源不存在");
|
||||
return resultDomain;
|
||||
}
|
||||
if (status == 1 && !resource.getIsAudited()) {
|
||||
ResultDomain<Boolean> pass = auditService.auditText(resource.getContent());
|
||||
if (pass.isSuccess() && pass.getData()) {
|
||||
resource.setIsAudited(true);
|
||||
} else {
|
||||
// 审核失败,标记状态为3(审核失败)
|
||||
resource.setStatus(3);
|
||||
resource.setUpdateTime(new Date());
|
||||
resourceMapper.updateResource(resource);
|
||||
|
||||
resultDomain.fail("审核失败");
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
// 更新状态
|
||||
resource.setStatus(status);
|
||||
resource.setUpdateTime(new Date());
|
||||
@@ -488,6 +511,21 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
if (!resource.getIsAudited()) {
|
||||
ResultDomain<Boolean> pass = auditService.auditText(resource.getContent());
|
||||
if (pass.isSuccess() && pass.getData()) {
|
||||
resource.setIsAudited(true);
|
||||
} else {
|
||||
// 审核失败,标记状态为3(审核失败)
|
||||
resource.setStatus(3);
|
||||
resource.setUpdateTime(new Date());
|
||||
resourceMapper.updateResource(resource);
|
||||
|
||||
resultDomain.fail("审核失败");
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新状态为已发布
|
||||
resource.setStatus(1);
|
||||
resource.setPublishTime(new Date());
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.xyzh.news.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xyzh.api.news.resource.ResourceAuditService;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
|
||||
/**
|
||||
* @description 资源审核服务实现类
|
||||
* @filename ResourceAuditServiceImpl.java
|
||||
*/
|
||||
@Service
|
||||
public class ResourceAuditServiceImpl implements ResourceAuditService {
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> auditText(String text) {
|
||||
ResultDomain<Boolean> result = new ResultDomain<Boolean>();
|
||||
// TODO: 文本审核逻辑(敏感词、违规词等规则校验)
|
||||
// 示例:直接通过
|
||||
result.success("审核通过", Boolean.TRUE);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> auditByFileId(String fileId) {
|
||||
ResultDomain<Boolean> result = new ResultDomain<Boolean>();
|
||||
// TODO:
|
||||
// 1. 根据 tb_sys_file.id 查询文件信息
|
||||
// 2. 读取文件内容,提取文本
|
||||
// 3. 调用 auditText(text) 进行审核
|
||||
// 4. 审核通过后,更新对应业务记录(tb_resource / tb_data_collection_item / tb_course_node) 的 is_audited = 1
|
||||
result.success("审核通过", Boolean.TRUE);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
<result column="like_count" property="likeCount" jdbcType="INTEGER"/>
|
||||
<result column="collect_count" property="collectCount" jdbcType="INTEGER"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="is_audited" property="isAudited" jdbcType="BOOLEAN"/>
|
||||
<result column="is_recommend" property="isRecommend" jdbcType="BOOLEAN"/>
|
||||
<result column="is_banner" property="isBanner" jdbcType="BOOLEAN"/>
|
||||
<result column="publish_time" property="publishTime" jdbcType="TIMESTAMP"/>
|
||||
@@ -32,7 +33,7 @@
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, resource_id, title, content, summary, cover_image, tag_id, author, source,
|
||||
source_url, view_count, like_count, collect_count, status, is_recommend,
|
||||
source_url, view_count, like_count, collect_count, status, is_audited, is_recommend,
|
||||
is_banner, publish_time, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
</sql>
|
||||
@@ -205,10 +206,10 @@
|
||||
<!-- 插入资源 -->
|
||||
<insert id="insertResource" parameterType="org.xyzh.common.dto.resource.TbResource">
|
||||
INSERT INTO tb_resource (
|
||||
id, resource_id, title, content, summary, cover_image, tag_id, author, source,
|
||||
id, resource_id, title, content, summary, cover_image, tag_id, author, source, is_audited,
|
||||
source_url, creator,create_time
|
||||
) VALUES (
|
||||
#{id}, #{resourceID}, #{title}, #{content}, #{summary}, #{coverImage}, #{tagID}, #{author}, #{source},
|
||||
#{id}, #{resourceID}, #{title}, #{content}, #{summary}, #{coverImage}, #{tagID}, #{author}, #{source}, #{isAudited},
|
||||
#{sourceUrl}, #{creator}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
@@ -259,6 +260,9 @@
|
||||
<if test="isBanner != null">
|
||||
is_banner = #{isBanner},
|
||||
</if>
|
||||
<if test="isAudited != null">
|
||||
is_audited = #{isAudited},
|
||||
</if>
|
||||
<if test="publishTime != null">
|
||||
publish_time = #{publishTime},
|
||||
</if>
|
||||
@@ -287,14 +291,14 @@
|
||||
<!-- 批量插入资源 -->
|
||||
<insert id="batchInsertResources" parameterType="java.util.List">
|
||||
INSERT INTO tb_resource (
|
||||
id, resource_id, title, content, summary, cover_image, tag_id, author, source,
|
||||
source_url, status, is_recommend, is_banner, publish_time,
|
||||
id, resource_id, title, content, summary, cover_image, tag_id, author, is_audited,
|
||||
source, source_url, status, is_recommend, is_banner, publish_time,
|
||||
creator, updater, create_time, update_time, deleted
|
||||
) VALUES
|
||||
<foreach collection="resourceList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.resourceID}, #{item.title}, #{item.content}, #{item.summary}, #{item.coverImage},
|
||||
#{item.tagID}, #{item.author}, #{item.source}, #{item.sourceUrl},
|
||||
#{item.tagID}, #{item.author}, #{item.isAudited}, #{item.source}, #{item.sourceUrl},
|
||||
#{item.status}, #{item.isRecommend}, #{item.isBanner}, #{item.publishTime},
|
||||
#{item.creator}, #{item.updater}, #{item.createTime}, #{item.updateTime}, #{item.deleted}
|
||||
)
|
||||
@@ -360,6 +364,7 @@
|
||||
<result column="like_count" property="likeCount" jdbcType="INTEGER"/>
|
||||
<result column="collect_count" property="collectCount" jdbcType="INTEGER"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="is_audited" property="isAudited" jdbcType="BOOLEAN"/>
|
||||
<result column="is_recommend" property="isRecommend" jdbcType="BOOLEAN"/>
|
||||
<result column="is_banner" property="isBanner" jdbcType="BOOLEAN"/>
|
||||
<result column="publish_time" property="publishTime" jdbcType="TIMESTAMP"/>
|
||||
|
||||
Reference in New Issue
Block a user