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;