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/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/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/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/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": 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/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); } 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