From 9ce6616fd3872c5c136d800445598316fdf9ec64 Mon Sep 17 00:00:00 2001 From: x ronger Date: Sat, 24 Oct 2020 23:23:31 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=87=E7=AB=A0=E5=BB=B6?= =?UTF-8?q?=E7=BB=AD=E9=98=85=E8=AF=BB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/rymcu/vertical/dto/PortfolioArticleDTO.java | 4 ++++ .../java/com/rymcu/vertical/mapper/ArticleMapper.java | 8 ++++++++ .../rymcu/vertical/service/impl/ArticleServiceImpl.java | 7 +++++++ src/main/java/mapper/ArticleMapper.xml | 6 +++++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java b/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java index adb755a..1916dd6 100644 --- a/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java @@ -2,6 +2,8 @@ package com.rymcu.vertical.dto; import lombok.Data; +import java.util.List; + /** * @author ronger */ @@ -20,4 +22,6 @@ public class PortfolioArticleDTO { private Integer sortNo; + private List articles; + } diff --git a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java index 10cc3ad..1c51297 100644 --- a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java @@ -168,4 +168,12 @@ public interface ArticleMapper extends Mapper
{ * @return */ Integer updateArticleLinkAndPreviewContent(@Param("idArticle") Integer idArticle, @Param("articleLink") String articleLink, @Param("articlePermalink") String articlePermalink, @Param("articlePreviewContent") String articlePreviewContent); + + /** + * 根据专题主键及当前文章排序号获取专题下文章大纲 + * @param idPortfolio + * @param sortNo + * @return + */ + List selectPortfolioArticlesByIdPortfolioAndSortNo(@Param("idPortfolio") Integer idPortfolio, @Param("sortNo") Integer sortNo); } 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 74a1349..5589d9f 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -350,6 +350,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti article.setArticleContent(articleContent.getArticleContentHtml()); // 获取所属作品集列表数据 List portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle()); + portfolioArticleDTOList.forEach(portfolioArticleDTO -> genPortfolioArticles(portfolioArticleDTO)); article.setPortfolios(portfolioArticleDTOList); } else if (type.equals(ARTICLE_EDIT)) { article.setArticleContent(articleContent.getArticleContent()); @@ -360,6 +361,12 @@ public class ArticleServiceImpl extends AbstractService
implements Arti return article; } + private PortfolioArticleDTO genPortfolioArticles(PortfolioArticleDTO portfolioArticleDTO) { + List articles = articleMapper.selectPortfolioArticlesByIdPortfolioAndSortNo(portfolioArticleDTO.getIdPortfolio(), portfolioArticleDTO.getSortNo()); + portfolioArticleDTO.setArticles(articles); + return portfolioArticleDTO; + } + private Author genAuthor(ArticleDTO article) { Author author = new Author(); author.setUserNickname(article.getArticleAuthorName()); diff --git a/src/main/java/mapper/ArticleMapper.xml b/src/main/java/mapper/ArticleMapper.xml index 85d471f..6a45224 100644 --- a/src/main/java/mapper/ArticleMapper.xml +++ b/src/main/java/mapper/ArticleMapper.xml @@ -60,6 +60,7 @@ + insert into vertical_article_content (id_article,article_content,article_content_html,created_time,updated_time) @@ -131,9 +132,12 @@ and instr(art.article_title, #{searchText}) > 0 and art.id not in (select id_vertical_article from vertical_portfolio_article where id_vertical_portfolio = #{idPortfolio}) order by updated_time desc + \ No newline at end of file