发布修改
This commit is contained in:
@@ -113,6 +113,13 @@ public interface ResourceService {
|
||||
*/
|
||||
ResultDomain<TbResource> publishResource(String resourceID);
|
||||
|
||||
/**
|
||||
* @description 强制发布资源(跳过敏感词校验)
|
||||
* @param resourceID 资源ID
|
||||
* @return ResultDomain<TbResource> 发布结果
|
||||
*/
|
||||
ResultDomain<TbResource> forcePublishResource(String resourceID);
|
||||
|
||||
/**
|
||||
* @description 下架资源
|
||||
* @param resourceID 资源ID
|
||||
|
||||
@@ -123,6 +123,14 @@ public class ResourceController {
|
||||
return resourceService.publishResource(resourceID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制发布资源(跳过敏感词校验)
|
||||
*/
|
||||
@PostMapping("/resource/{resourceID}/force-publish")
|
||||
public ResultDomain<TbResource> forcePublishResource(@PathVariable("resourceID") String resourceID) {
|
||||
return resourceService.forcePublishResource(resourceID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下架资源
|
||||
*/
|
||||
|
||||
@@ -647,6 +647,61 @@ public class NCResourceServiceImpl implements ResourceService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultDomain<TbResource> forcePublishResource(String resourceID) {
|
||||
ResultDomain<TbResource> resultDomain = new ResultDomain<>();
|
||||
try {
|
||||
// 参数验证
|
||||
if (!StringUtils.hasText(resourceID)) {
|
||||
resultDomain.fail("资源ID不能为空");
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
// 查询资源
|
||||
TbResource resource = resourceMapper.selectByResourceId(resourceID);
|
||||
if (resource == null || resource.getDeleted()) {
|
||||
resultDomain.fail("资源不存在");
|
||||
return resultDomain;
|
||||
}
|
||||
|
||||
// 强制发布:跳过敏感词校验,直接设置为已审核通过
|
||||
resource.setIsAudited(true);
|
||||
resource.setStatus(1);
|
||||
resource.setPublishTime(new Date());
|
||||
resource.setUpdateTime(new Date());
|
||||
|
||||
int result = resourceMapper.updateResource(resource);
|
||||
if (result > 0) {
|
||||
logger.info("强制发布资源成功: {}", resourceID);
|
||||
// 重新查询返回完整数据
|
||||
TbResource updated = resourceMapper.selectByResourceId(resourceID);
|
||||
|
||||
// 异步将文章导入知识库
|
||||
try {
|
||||
ResultDomain<TbResource> knowledgeResult = articleKnowledgeService.importArticleToDefaultKnowledge(updated);
|
||||
if (knowledgeResult.isSuccess() && knowledgeResult.getData() != null) {
|
||||
logger.info("强制发布文章已成功导入知识库: {}", resourceID);
|
||||
} else {
|
||||
logger.warn("强制发布文章导入知识库跳过或失败: {}, 原因: {}", resourceID, knowledgeResult.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("强制发布文章导入知识库异常,但不影响发布: {}", e.getMessage(), e);
|
||||
}
|
||||
|
||||
resultDomain.success("强制发布资源成功", updated);
|
||||
return resultDomain;
|
||||
} else {
|
||||
resultDomain.fail("强制发布资源失败");
|
||||
return resultDomain;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("强制发布资源异常: {}", e.getMessage(), e);
|
||||
resultDomain.fail("强制发布资源失败: " + e.getMessage());
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultDomain<TbResource> unpublishResource(String resourceID) {
|
||||
|
||||
@@ -118,6 +118,16 @@ export const resourceApi = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 强制发布资源(跳过敏感词校验)
|
||||
* @param resourceID 资源ID
|
||||
* @returns Promise<ResultDomain<Resource>>
|
||||
*/
|
||||
async forcePublishResource(resourceID: string): Promise<ResultDomain<Resource>> {
|
||||
const response = await api.post<Resource>(`/news/resources/resource/${resourceID}/force-publish`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 下架资源
|
||||
* @param resourceID 资源ID
|
||||
|
||||
@@ -52,6 +52,14 @@
|
||||
>
|
||||
{{ getActionButtonText(row.status) }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === ResourceStatus.SENSITIVE_FAILED"
|
||||
size="small"
|
||||
type="warning"
|
||||
@click="forcePublishArticle(row)"
|
||||
>
|
||||
强制发布
|
||||
</el-button>
|
||||
<el-button size="small" @click="editArticle(row)">编辑</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
@@ -225,6 +233,32 @@ async function changeArticleStatus(row: Resource) {
|
||||
}
|
||||
}
|
||||
|
||||
async function forcePublishArticle(row: Resource) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要强制发布文章「${row.title}」吗?此操作将跳过敏感词校验。`,
|
||||
'强制发布确认',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
);
|
||||
const res = await resourceApi.forcePublishResource(row.resourceID!);
|
||||
if (res.success) {
|
||||
ElMessage.success('强制发布成功');
|
||||
loadArticles();
|
||||
} else {
|
||||
ElMessage.error(res.message || '强制发布失败');
|
||||
}
|
||||
} catch (error) {
|
||||
if (error !== 'cancel') {
|
||||
console.error('强制发布失败:', error);
|
||||
ElMessage.error('强制发布失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleEditFromView() {
|
||||
if (currentArticle.value?.resourceID) {
|
||||
showViewDialog.value = false;
|
||||
|
||||
Reference in New Issue
Block a user