diff --git a/pom.xml b/pom.xml index 16c8bbc..bd2ce30 100644 --- a/pom.xml +++ b/pom.xml @@ -180,11 +180,6 @@ weixin-java-open 3.7.0 - - com.github.binarywang - java-emoji-converter - 1.0.0 - diff --git a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java index 50cedc3..aaa0759 100644 --- a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java @@ -53,4 +53,6 @@ public class ArticleDTO { private List articleComments; private List portfolios; + + private Integer sortNo; } diff --git a/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java b/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java index e50c381..adb755a 100644 --- a/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java @@ -18,4 +18,6 @@ public class PortfolioArticleDTO { private String portfolioTitle; + private Integer sortNo; + } diff --git a/src/main/java/com/rymcu/vertical/entity/Portfolio.java b/src/main/java/com/rymcu/vertical/entity/Portfolio.java index c18877a..3cd2482 100644 --- a/src/main/java/com/rymcu/vertical/entity/Portfolio.java +++ b/src/main/java/com/rymcu/vertical/entity/Portfolio.java @@ -28,6 +28,8 @@ public class Portfolio { private Integer portfolioAuthorId; /** 作品集介绍 */ private String portfolioDescription; + /** 作品集介绍 Html */ + private String portfolioDescriptionHtml; /** 创建时间 */ private Date createdTime; /** 更新时间 */ diff --git a/src/main/java/com/rymcu/vertical/mapper/PortfolioMapper.java b/src/main/java/com/rymcu/vertical/mapper/PortfolioMapper.java index c259b09..f9a11fb 100644 --- a/src/main/java/com/rymcu/vertical/mapper/PortfolioMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/PortfolioMapper.java @@ -21,9 +21,10 @@ public interface PortfolioMapper extends Mapper { /** * 查询作品集 * @param id + * @param type * @return */ - PortfolioDTO selectPortfolioDTOById(@Param("id") Integer id); + PortfolioDTO selectPortfolioDTOById(@Param("id") Integer id, @Param("type") Integer type); /** * 统计作品集下文章数 @@ -55,4 +56,13 @@ public interface PortfolioMapper extends Mapper { * @return */ Integer selectMaxSortNo(@Param("idPortfolio") Integer idPortfolio); + + /** + * 更新文章排序号 + * @param idPortfolio + * @param idArticle + * @param sortNo + * @return + */ + Integer updateArticleSortNo(@Param("idPortfolio") Integer idPortfolio, @Param("idArticle") Integer idArticle, @Param("sortNo") Integer sortNo); } diff --git a/src/main/java/com/rymcu/vertical/service/PortfolioService.java b/src/main/java/com/rymcu/vertical/service/PortfolioService.java index 9291e5c..ffd5241 100644 --- a/src/main/java/com/rymcu/vertical/service/PortfolioService.java +++ b/src/main/java/com/rymcu/vertical/service/PortfolioService.java @@ -24,9 +24,10 @@ public interface PortfolioService extends Service { /** 查询作品集 * @param idPortfolio + * @param type * @return */ - PortfolioDTO findPortfolioDTOById(Integer idPortfolio); + PortfolioDTO findPortfolioDTOById(Integer idPortfolio, Integer type); /** * 保持/更新作品集 @@ -54,4 +55,11 @@ public interface PortfolioService extends Service { * @return */ Map bindArticle(PortfolioArticleDTO portfolioArticle); + + /** + * 更新文章排序号 + * @param portfolioArticle + * @return + */ + Map updateArticleSortNo(PortfolioArticleDTO portfolioArticle); } diff --git a/src/main/java/com/rymcu/vertical/service/impl/PortfolioServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/PortfolioServiceImpl.java index 3fc3a32..0cb5cb4 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/PortfolioServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/PortfolioServiceImpl.java @@ -48,8 +48,8 @@ public class PortfolioServiceImpl extends AbstractService implements } @Override - public PortfolioDTO findPortfolioDTOById(Integer idPortfolio) { - PortfolioDTO portfolio = portfolioMapper.selectPortfolioDTOById(idPortfolio); + public PortfolioDTO findPortfolioDTOById(Integer idPortfolio, Integer type) { + PortfolioDTO portfolio = portfolioMapper.selectPortfolioDTOById(idPortfolio,type); Author author = userService.selectAuthor(portfolio.getPortfolioAuthorId()); genPortfolioAuthor(portfolio,author); Integer articleNumber = portfolioMapper.selectCountArticleNumber(portfolio.getIdPortfolio()); @@ -106,6 +106,27 @@ public class PortfolioServiceImpl extends AbstractService implements return map; } + @Override + public Map updateArticleSortNo(PortfolioArticleDTO portfolioArticle) { + Map map = new HashMap(1); + if (portfolioArticle.getIdPortfolio() == null || portfolioArticle.getIdPortfolio() == 0) { + map.put("message", "作品集数据异常!"); + } + if (portfolioArticle.getIdArticle() == null || portfolioArticle.getIdArticle() == 0) { + map.put("message", "文章数据异常!"); + } + if (portfolioArticle.getSortNo() == null) { + map.put("message", "排序号不能为空!"); + } + Integer result = portfolioMapper.updateArticleSortNo(portfolioArticle.getIdPortfolio(),portfolioArticle.getIdArticle(),portfolioArticle.getSortNo()); + if (result > 0) { + map.put("message", "更新成功!"); + } else { + map.put("message", "更新失败!"); + } + return map; + } + private PortfolioDTO genPortfolioAuthor(PortfolioDTO portfolioDTO, Author author) { portfolioDTO.setPortfolioAuthorAvatarUrl(author.getUserAvatarURL()); portfolioDTO.setPortfolioAuthorName(author.getUserNickname()); diff --git a/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java index 311fc80..722b5bc 100644 --- a/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java @@ -124,7 +124,7 @@ public class CommonApiController { @GetMapping("/portfolio/{id}") @VisitLogger public GlobalResult> portfolio(@PathVariable Integer id){ - PortfolioDTO portfolioDTO = portfolioService.findPortfolioDTOById(id); + PortfolioDTO portfolioDTO = portfolioService.findPortfolioDTOById(id,1); Map map = new HashMap<>(1); map.put("portfolio", portfolioDTO); return GlobalResultGenerator.genSuccessResult(map); diff --git a/src/main/java/com/rymcu/vertical/web/api/portfolio/PortfolioController.java b/src/main/java/com/rymcu/vertical/web/api/portfolio/PortfolioController.java index 0f0f53a..425b681 100644 --- a/src/main/java/com/rymcu/vertical/web/api/portfolio/PortfolioController.java +++ b/src/main/java/com/rymcu/vertical/web/api/portfolio/PortfolioController.java @@ -24,8 +24,8 @@ public class PortfolioController { private PortfolioService portfolioService; @GetMapping("/detail/{id}") - public GlobalResult detail(@PathVariable Integer id) { - PortfolioDTO portfolio = portfolioService.findPortfolioDTOById(id); + public GlobalResult detail(@PathVariable Integer id,@RequestParam(defaultValue = "0") Integer type) { + PortfolioDTO portfolio = portfolioService.findPortfolioDTOById(id, type); Map map = new HashMap<>(1); map.put("portfolio", portfolio); return GlobalResultGenerator.genSuccessResult(map); @@ -55,4 +55,10 @@ public class PortfolioController { return GlobalResultGenerator.genSuccessResult(map); } + @PutMapping("/update-article-sort-no") + public GlobalResult updateArticleSortNo(@RequestBody PortfolioArticleDTO portfolioArticle) { + Map map = portfolioService.updateArticleSortNo(portfolioArticle); + return GlobalResultGenerator.genSuccessResult(map); + } + } diff --git a/src/main/java/mapper/ArticleMapper.xml b/src/main/java/mapper/ArticleMapper.xml index f2c10f5..526982c 100644 --- a/src/main/java/mapper/ArticleMapper.xml +++ b/src/main/java/mapper/ArticleMapper.xml @@ -37,6 +37,7 @@ + @@ -108,8 +109,8 @@ select art.*,su.nickname,su.avatar_url from vertical_article art left join vertical_user su on art.article_author_id = su.id where article_status = '1' and art.article_author_id = #{idUser} order by updated_time desc select id, portfolio_head_img_url, portfolio_title, portfolio_author_id, portfolio_description, updated_time from vertical_portfolio where portfolio_author_id = #{idUser}