From baa49a22e43219d74cbdbb1c69822a61656a07bb Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 7 May 2021 08:27:36 +0800 Subject: [PATCH] =?UTF-8?q?:poop:=20=E5=85=AC=E5=91=8A=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/rymcu/forest/dto/ForgetPasswordDTO.java | 3 +++ .../java/com/rymcu/forest/mapper/ArticleMapper.java | 6 ++++++ .../java/com/rymcu/forest/service/ArticleService.java | 7 +++++++ .../rymcu/forest/service/impl/ArticleServiceImpl.java | 9 +++++++++ .../forest/web/api/common/CommonApiController.java | 10 ++++++++++ src/main/java/mapper/ArticleMapper.xml | 7 +++++++ 6 files changed, 42 insertions(+) diff --git a/src/main/java/com/rymcu/forest/dto/ForgetPasswordDTO.java b/src/main/java/com/rymcu/forest/dto/ForgetPasswordDTO.java index 49d6112..4c653cc 100644 --- a/src/main/java/com/rymcu/forest/dto/ForgetPasswordDTO.java +++ b/src/main/java/com/rymcu/forest/dto/ForgetPasswordDTO.java @@ -2,6 +2,9 @@ package com.rymcu.forest.dto; import lombok.Data; +/** + * @author ronger + */ @Data public class ForgetPasswordDTO { private String code; diff --git a/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java b/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java index 58a34d2..8ae9083 100644 --- a/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java @@ -190,4 +190,10 @@ public interface ArticleMapper extends Mapper
{ * @param idArticle */ void deleteArticleContent(@Param("idArticle") Integer idArticle); + + /** + * 获取公告 + * @return + */ + List selectAnnouncements(); } diff --git a/src/main/java/com/rymcu/forest/service/ArticleService.java b/src/main/java/com/rymcu/forest/service/ArticleService.java index f564de9..83174df 100644 --- a/src/main/java/com/rymcu/forest/service/ArticleService.java +++ b/src/main/java/com/rymcu/forest/service/ArticleService.java @@ -66,6 +66,7 @@ public interface ArticleService extends Service
{ * 删除文章 * @param id * @return + * @throws BaseApiException * */ Map delete(Integer id) throws BaseApiException; @@ -123,4 +124,10 @@ public interface ArticleService extends Service
{ * @return */ Map updatePerfect(Integer idArticle, String articlePerfect); + + /** + * 获取公告列表 + * @return + */ + List findAnnouncements(); } diff --git a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java index 5308dc0..d0aa3f9 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java @@ -364,6 +364,15 @@ public class ArticleServiceImpl extends AbstractService
implements Arti return map; } + @Override + public List findAnnouncements() { + List list = articleMapper.selectAnnouncements(); + list.forEach(article -> { + genArticle(article, 0); + }); + return list; + } + private ArticleDTO genArticle(ArticleDTO article, Integer type) { Integer articleList = 0; Integer articleView = 1; diff --git a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java index 88d4931..9ec0389 100644 --- a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java @@ -97,6 +97,16 @@ public class CommonApiController { return GlobalResultGenerator.genSuccessResult(map); } + @GetMapping("/announcements") + @VisitLogger + public GlobalResult announcements(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "5") Integer rows){ + PageHelper.startPage(page, rows); + List list = articleService.findAnnouncements(); + PageInfo pageInfo = new PageInfo(list); + Map map = Utils.getArticlesGlobalResult(pageInfo); + return GlobalResultGenerator.genSuccessResult(map); + } + @GetMapping("/article/{id}") @VisitLogger public GlobalResult> article(@PathVariable Integer id){ diff --git a/src/main/java/mapper/ArticleMapper.xml b/src/main/java/mapper/ArticleMapper.xml index 6b8fd88..3e9d852 100644 --- a/src/main/java/mapper/ArticleMapper.xml +++ b/src/main/java/mapper/ArticleMapper.xml @@ -105,6 +105,7 @@ where article_status = 0 and FIND_IN_SET('划水',art.article_tags) = 0 + and FIND_IN_SET('公告',art.article_tags) = 0 order by updated_time desc @@ -155,4 +156,10 @@ select va.article_title, va.id, va.article_permalink from forest_portfolio_article vpa join forest_article va on va.id = vpa.id_article where va.article_status = '0' and id_portfolio = #{idPortfolio} order by sort_no + \ No newline at end of file