|
@@ -302,7 +302,7 @@ public class ArticleService {
|
|
|
|
|
|
|
|
public Page<Article> getAdminList(String status, Long categoryId, String keyword,
|
|
public Page<Article> getAdminList(String status, Long categoryId, String keyword,
|
|
|
String contentType, Integer difficultyLevel,
|
|
String contentType, Integer difficultyLevel,
|
|
|
- String dimensionCode, Long tagId, int page, int size) {
|
|
|
|
|
|
|
+ String dimensionCode, Long tagId, String auditStatus, int page, int size) {
|
|
|
LambdaQueryWrapper<Article> wrapper = new LambdaQueryWrapper<Article>()
|
|
LambdaQueryWrapper<Article> wrapper = new LambdaQueryWrapper<Article>()
|
|
|
.orderByDesc(Article::getCreatedAt);
|
|
.orderByDesc(Article::getCreatedAt);
|
|
|
|
|
|
|
@@ -327,6 +327,9 @@ public class ArticleService {
|
|
|
if (tagId != null && tagId > 0) {
|
|
if (tagId != null && tagId > 0) {
|
|
|
wrapper.inSql(Article::getId, "SELECT article_id FROM article_tags WHERE tag_id = " + tagId);
|
|
wrapper.inSql(Article::getId, "SELECT article_id FROM article_tags WHERE tag_id = " + tagId);
|
|
|
}
|
|
}
|
|
|
|
|
+ if (auditStatus != null && !auditStatus.isEmpty()) {
|
|
|
|
|
+ wrapper.eq(Article::getAuditStatus, auditStatus);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return articleMapper.selectPage(new Page<>(page, size), wrapper);
|
|
return articleMapper.selectPage(new Page<>(page, size), wrapper);
|
|
|
}
|
|
}
|
|
@@ -670,6 +673,9 @@ public class ArticleService {
|
|
|
if (article == null) {
|
|
if (article == null) {
|
|
|
throw new RuntimeException("文章不存在");
|
|
throw new RuntimeException("文章不存在");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!"pending".equals(article.getAuditStatus())) {
|
|
|
|
|
+ throw new RuntimeException("仅待审核状态可审核");
|
|
|
|
|
+ }
|
|
|
article.setAuditStatus(auditStatus);
|
|
article.setAuditStatus(auditStatus);
|
|
|
article.setAuditorId(auditorId);
|
|
article.setAuditorId(auditorId);
|
|
|
article.setAuditedAt(new Date());
|
|
article.setAuditedAt(new Date());
|
|
@@ -678,13 +684,14 @@ public class ArticleService {
|
|
|
article.setPublishedAt(new Date());
|
|
article.setPublishedAt(new Date());
|
|
|
article.setAuditReason(null);
|
|
article.setAuditReason(null);
|
|
|
} else if ("rejected".equals(auditStatus)) {
|
|
} else if ("rejected".equals(auditStatus)) {
|
|
|
- article.setStatus("draft");
|
|
|
|
|
|
|
+ article.setStatus("rejected");
|
|
|
article.setAuditReason(auditReason);
|
|
article.setAuditReason(auditReason);
|
|
|
}
|
|
}
|
|
|
article.setUpdatedAt(new Date());
|
|
article.setUpdatedAt(new Date());
|
|
|
articleMapper.updateById(article);
|
|
articleMapper.updateById(article);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
/**
|
|
/**
|
|
|
* 调用 Dify AI 从文章内容中自动提取 3-5 个中文关键词作为标签
|
|
* 调用 Dify AI 从文章内容中自动提取 3-5 个中文关键词作为标签
|
|
|
*/
|
|
*/
|
|
@@ -773,5 +780,52 @@ public class ArticleService {
|
|
|
String tagsStr = String.join(",", savedTags);
|
|
String tagsStr = String.join(",", savedTags);
|
|
|
jdbcTemplate.update("UPDATE articles SET tags = ? WHERE id = ?", tagsStr, articleId);
|
|
jdbcTemplate.update("UPDATE articles SET tags = ? WHERE id = ?", tagsStr, articleId);
|
|
|
}
|
|
}
|
|
|
|
|
+=======
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public void submitForReview(Long id) {
|
|
|
|
|
+ Article article = articleMapper.selectById(id);
|
|
|
|
|
+ if (article == null) {
|
|
|
|
|
+ throw new RuntimeException("文章不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!"draft".equals(article.getStatus())) {
|
|
|
|
|
+ throw new RuntimeException("仅草稿状态可提交审核");
|
|
|
|
|
+ }
|
|
|
|
|
+ article.setStatus("pending");
|
|
|
|
|
+ article.setAuditStatus("pending");
|
|
|
|
|
+ article.setUpdatedAt(new Date());
|
|
|
|
|
+ articleMapper.updateById(article);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public void withdraw(Long id) {
|
|
|
|
|
+ Article article = articleMapper.selectById(id);
|
|
|
|
|
+ if (article == null) {
|
|
|
|
|
+ throw new RuntimeException("文章不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!"published".equals(article.getStatus())) {
|
|
|
|
|
+ throw new RuntimeException("仅发布中的文章可撤回");
|
|
|
|
|
+ }
|
|
|
|
|
+ article.setStatus("withdrawn");
|
|
|
|
|
+ article.setUpdatedAt(new Date());
|
|
|
|
|
+ articleMapper.updateById(article);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public void reDraft(Long id) {
|
|
|
|
|
+ Article article = articleMapper.selectById(id);
|
|
|
|
|
+ if (article == null) {
|
|
|
|
|
+ throw new RuntimeException("文章不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!"rejected".equals(article.getStatus())) {
|
|
|
|
|
+ throw new RuntimeException("仅已驳回的文章可重新编辑");
|
|
|
|
|
+ }
|
|
|
|
|
+ article.setStatus("draft");
|
|
|
|
|
+ article.setAuditStatus(null);
|
|
|
|
|
+ article.setAuditReason(null);
|
|
|
|
|
+ article.setAuditorId(null);
|
|
|
|
|
+ article.setAuditedAt(null);
|
|
|
|
|
+ article.setUpdatedAt(new Date());
|
|
|
|
|
+ articleMapper.updateById(article);
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|