From 33d7856bd5367363b4c14f5bfc5bec0e51c4ee5b Mon Sep 17 00:00:00 2001 From: x ronger Date: Tue, 24 Mar 2020 01:05:03 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=B8=93=E9=A2=98=E9=A1=B5=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BB=93=E6=9E=84=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/vertical/service/ArticleService.java | 4 ++-- .../vertical/service/impl/ArticleServiceImpl.java | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/rymcu/vertical/service/ArticleService.java b/src/main/java/com/rymcu/vertical/service/ArticleService.java index 541bf57..30325a3 100644 --- a/src/main/java/com/rymcu/vertical/service/ArticleService.java +++ b/src/main/java/com/rymcu/vertical/service/ArticleService.java @@ -26,10 +26,10 @@ public interface ArticleService extends Service
{ /** * 查询文章详情信息 * @param id - * @param i + * @param type * @return * */ - ArticleDTO findArticleDTOById(Integer id, int i); + ArticleDTO findArticleDTOById(Integer id, Integer type); /** * 查询主题下文章列表 diff --git a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java index f451556..802c65a 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -66,7 +66,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti } @Override - public ArticleDTO findArticleDTOById(Integer id, int type) { + public ArticleDTO findArticleDTOById(Integer id, Integer type) { ArticleDTO articleDTO = articleMapper.selectArticleDTOById(id,type); if (articleDTO == null) { return null; @@ -78,6 +78,9 @@ public class ArticleServiceImpl extends AbstractService
implements Arti @Override public List findArticlesByTopicUri(String name) { List articleDTOS = articleMapper.selectArticlesByTopicUri(name); + articleDTOS.forEach(articleDTO -> { + genArticle(articleDTO,0); + }); return articleDTOS; } @@ -266,16 +269,14 @@ public class ArticleServiceImpl extends AbstractService
implements Arti article.setTimeAgo(Utils.getTimeAgo(article.getUpdatedTime())); List tags = articleMapper.selectTags(article.getIdArticle()); article.setTags(tags); - if(type == 1){ - ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); + ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); + if (type == 1){ article.setArticleContent(articleContent.getArticleContentHtml()); - } else if(type == 2){ - ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); + } else if (type == 2) { article.setArticleContent(articleContent.getArticleContent()); } if(StringUtils.isBlank(article.getArticlePreviewContent())){ - ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); Integer length = articleContent.getArticleContentHtml().length(); if(length > MAX_PREVIEW){ length = 200;