From 1aa4797ef786f02582ffb825da8b1a250c778948 Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 24 Feb 2021 09:16:48 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=96=87=E7=AB=A0=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=BF=87=E5=B0=91=E8=B0=83=E7=94=A8=E7=99=BE=E5=BA=A6=E6=91=98?= =?UTF-8?q?=E8=A6=81=20api=20=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rymcu/forest/service/impl/ArticleServiceImpl.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java index 386dee6..9bbbb54 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java @@ -187,9 +187,14 @@ public class ArticleServiceImpl extends AbstractService
implements Arti } if (StringUtils.isNotBlank(articleContentHtml)) { - String previewContent = BaiDuAipUtils.getNewsSummary(newArticle.getArticleTitle(), articleContentHtml, MAX_PREVIEW); - if (previewContent.length() > MAX_PREVIEW) { - previewContent = previewContent.substring(0, 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); }