From fe61bf1945707a8dea47f073296ad36f2ebd9052 Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 27 Apr 2021 21:47:07 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E4=BD=9C?= =?UTF-8?q?=E5=93=81=E9=9B=86=E9=89=B4=E6=9D=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/forest/service/PortfolioService.java | 2 +- .../forest/service/impl/PortfolioServiceImpl.java | 13 ++++++++++++- .../web/api/portfolio/PortfolioController.java | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/rymcu/forest/service/PortfolioService.java b/src/main/java/com/rymcu/forest/service/PortfolioService.java index df8d2e7..db6d67c 100644 --- a/src/main/java/com/rymcu/forest/service/PortfolioService.java +++ b/src/main/java/com/rymcu/forest/service/PortfolioService.java @@ -76,7 +76,7 @@ public interface PortfolioService extends Service { * @param idPortfolio * @return */ - Map deletePortfolio(Integer idPortfolio); + Map deletePortfolio(Integer idPortfolio) throws BaseApiException; /** * 获取作品集列表数据 diff --git a/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java index b843722..cbc480c 100644 --- a/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java @@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.rymcu.forest.core.service.AbstractService; import com.rymcu.forest.dto.*; +import com.rymcu.forest.entity.Article; import com.rymcu.forest.entity.Portfolio; import com.rymcu.forest.entity.User; import com.rymcu.forest.mapper.PortfolioMapper; @@ -152,11 +153,21 @@ public class PortfolioServiceImpl extends AbstractService implements } @Override - public Map deletePortfolio(Integer idPortfolio) { + public Map deletePortfolio(Integer idPortfolio) throws BaseApiException { Map map = new HashMap(1); if (idPortfolio == null || idPortfolio.equals(0)) { map.put("message", "作品集数据异常"); } + // 鉴权 + User user = UserUtils.getCurrentUserByToken(); + Integer roleWeights = userService.findRoleWeightsByUser(user.getIdUser()); + if (roleWeights > 2) { + Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio); + if (!user.getIdUser().equals(portfolio.getPortfolioAuthorId())) { + map.put("message", "非法访问!"); + return map; + } + } Integer articleNumber = portfolioMapper.selectCountArticleNumber(idPortfolio); if (articleNumber > 0) { diff --git a/src/main/java/com/rymcu/forest/web/api/portfolio/PortfolioController.java b/src/main/java/com/rymcu/forest/web/api/portfolio/PortfolioController.java index 66251cb..ffaaf73 100644 --- a/src/main/java/com/rymcu/forest/web/api/portfolio/PortfolioController.java +++ b/src/main/java/com/rymcu/forest/web/api/portfolio/PortfolioController.java @@ -68,7 +68,7 @@ public class PortfolioController { } @DeleteMapping("/delete") - public GlobalResult delete(Integer idPortfolio){ + public GlobalResult delete(Integer idPortfolio) throws BaseApiException { Map map = portfolioService.deletePortfolio(idPortfolio); return GlobalResultGenerator.genSuccessResult(map); } From baa49a22e43219d74cbdbb1c69822a61656a07bb Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 7 May 2021 08:27:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:poop:=20=E5=85=AC=E5=91=8A=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=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 From dad3a1460ef0dd4b9d84e9ac2bcb20697f584b2b Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 11 May 2021 15:24:22 +0800 Subject: [PATCH 3/3] =?UTF-8?q?:bug:=20=E6=B6=88=E6=81=AF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5-=E8=AF=84=E8=AE=BA=E8=A2=AB=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=90=8E=E6=95=B0=E6=8D=AE=E5=8A=A0=E8=BD=BD=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/forest/util/NotificationUtils.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/rymcu/forest/util/NotificationUtils.java b/src/main/java/com/rymcu/forest/util/NotificationUtils.java index c6b0500..9f5c9a4 100644 --- a/src/main/java/com/rymcu/forest/util/NotificationUtils.java +++ b/src/main/java/com/rymcu/forest/util/NotificationUtils.java @@ -123,12 +123,14 @@ public class NotificationUtils { case "2": // 回帖 comment = commentService.findById(notification.getDataId().toString()); - article = articleService.findArticleDTOById(comment.getCommentArticleId(), 0); - if (Objects.nonNull(article)) { - notificationDTO.setDataTitle(article.getArticleTitle()); - notificationDTO.setDataUrl(comment.getCommentSharpUrl()); - user = userService.findById(comment.getCommentAuthorId().toString()); - notificationDTO.setAuthor(genAuthor(user)); + if (Objects.nonNull(comment)) { + article = articleService.findArticleDTOById(comment.getCommentArticleId(), 0); + if (Objects.nonNull(article)) { + notificationDTO.setDataTitle(article.getArticleTitle()); + notificationDTO.setDataUrl(comment.getCommentSharpUrl()); + user = userService.findById(comment.getCommentAuthorId().toString()); + notificationDTO.setAuthor(genAuthor(user)); + } } break; case "3":