🐛 文章内容过少调用百度摘要 api 失败问题修复

This commit is contained in:
ronger 2021-02-24 09:16:48 +08:00
parent eacb753e55
commit 1aa4797ef7

View File

@ -187,10 +187,15 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
}
if (StringUtils.isNotBlank(articleContentHtml)) {
String previewContent = BaiDuAipUtils.getNewsSummary(newArticle.getArticleTitle(), articleContentHtml, MAX_PREVIEW);
String previewContent;
if (articleContentHtml.length() > MAX_PREVIEW) {
previewContent = BaiDuAipUtils.getNewsSummary(newArticle.getArticleTitle(), articleContentHtml, MAX_PREVIEW);
if (previewContent.length() > MAX_PREVIEW) {
previewContent = previewContent.substring(0, MAX_PREVIEW);
}
} else {
previewContent = Html2TextUtil.getContent(articleContentHtml);
}
newArticle.setArticlePreviewContent(previewContent);
}
articleMapper.updateByPrimaryKeySelective(newArticle);