|
|
@@ -18,6 +18,7 @@ import javax.annotation.Resource;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.concurrent.Future;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import com.etotem.cfc.util.SortUtil;
|
|
|
@@ -94,10 +95,17 @@ public class AdminArticleController {
|
|
|
if (!checkTextSafe(content)) {
|
|
|
return Result.error("文章内容包含敏感信息,发布失败");
|
|
|
}
|
|
|
+ if (!checkTextSafe((String) body.get("audioText"))) {
|
|
|
+ return Result.error("朗读文本包含敏感信息,发布失败");
|
|
|
+ }
|
|
|
|
|
|
Article article = new Article();
|
|
|
article.setTitle((String) body.get("title"));
|
|
|
article.setContent((String) body.get("content"));
|
|
|
+ // 朗读文本(TTS 专用;留空则自动从正文生成)
|
|
|
+ if (body.get("audioText") != null) {
|
|
|
+ article.setAudioText(body.get("audioText").toString());
|
|
|
+ }
|
|
|
if (body.get("categoryId") != null && !body.get("categoryId").toString().trim().isEmpty()) {
|
|
|
article.setCategoryId(ParamUtils.getLong(body.get("categoryId")));
|
|
|
}
|
|
|
@@ -169,10 +177,14 @@ public class AdminArticleController {
|
|
|
if (!checkTextSafe(content)) {
|
|
|
return Result.error("文章内容包含敏感信息,更新失败");
|
|
|
}
|
|
|
+ if (!checkTextSafe((String) body.get("audioText"))) {
|
|
|
+ return Result.error("朗读文本包含敏感信息,更新失败");
|
|
|
+ }
|
|
|
|
|
|
Long articleId = ParamUtils.getLong(body.get("id"));
|
|
|
+ Article existing = null;
|
|
|
if (articleId != null) {
|
|
|
- Article existing = articleService.getById(articleId);
|
|
|
+ existing = articleService.getById(articleId);
|
|
|
if (existing != null && !"draft".equals(existing.getStatus())
|
|
|
&& !"published".equals(existing.getStatus())
|
|
|
&& !"withdrawn".equals(existing.getStatus())) {
|
|
|
@@ -226,6 +238,13 @@ public class AdminArticleController {
|
|
|
} else if (articleTypeVal instanceof String) {
|
|
|
article.setArticleType((String) articleTypeVal);
|
|
|
}
|
|
|
+ // 朗读文本(TTS 专用;留空则从正文生成)。变更时作废已生成音频,下次「听文章」重新合成
|
|
|
+ if (body.get("audioText") != null) {
|
|
|
+ article.setAudioText(body.get("audioText").toString());
|
|
|
+ if (existing != null && !Objects.equals(existing.getAudioText(), article.getAudioText())) {
|
|
|
+ article.setAudioUrl("");
|
|
|
+ }
|
|
|
+ }
|
|
|
articleService.update(article);
|
|
|
|
|
|
return Result.success("更新成功");
|