🐛 展示文章预览内容

This commit is contained in:
x ronger 2020-01-15 01:00:18 +08:00
parent 90c9d31527
commit 44defa3aa9

View File

@ -176,16 +176,16 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
} else if(type == 2){ } else if(type == 2){
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
article.setArticleContent(articleContent.getArticleContent()); article.setArticleContent(articleContent.getArticleContent());
} else { }
if(StringUtils.isBlank(article.getArticlePreviewContent())){
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); if(StringUtils.isBlank(article.getArticlePreviewContent())){
Integer length = articleContent.getArticleContentHtml().length(); ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
if(length > MAX_PREVIEW){ Integer length = articleContent.getArticleContentHtml().length();
length = 200; if(length > MAX_PREVIEW){
} length = 200;
String articlePreviewContent = articleContent.getArticleContentHtml().substring(0,length); }
article.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent)); String articlePreviewContent = articleContent.getArticleContentHtml().substring(0,length);
} article.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent));
} }
return article; return article;
} }