🐛 修复了一些问题

* 修复作品集鉴权问题
* 消息通知-评论被删除后数据加载失败问题修复
* 添加公告组件 API
This commit is contained in:
ronger 2021-05-28 18:55:45 +08:00 committed by GitHub
commit c9e38b0ddb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 64 additions and 9 deletions

View File

@ -2,6 +2,9 @@ package com.rymcu.forest.dto;
import lombok.Data; import lombok.Data;
/**
* @author ronger
*/
@Data @Data
public class ForgetPasswordDTO { public class ForgetPasswordDTO {
private String code; private String code;

View File

@ -190,4 +190,10 @@ public interface ArticleMapper extends Mapper<Article> {
* @param idArticle * @param idArticle
*/ */
void deleteArticleContent(@Param("idArticle") Integer idArticle); void deleteArticleContent(@Param("idArticle") Integer idArticle);
/**
* 获取公告
* @return
*/
List<ArticleDTO> selectAnnouncements();
} }

View File

@ -66,6 +66,7 @@ public interface ArticleService extends Service<Article> {
* 删除文章 * 删除文章
* @param id * @param id
* @return * @return
* @throws BaseApiException
* */ * */
Map delete(Integer id) throws BaseApiException; Map delete(Integer id) throws BaseApiException;
@ -123,4 +124,10 @@ public interface ArticleService extends Service<Article> {
* @return * @return
*/ */
Map updatePerfect(Integer idArticle, String articlePerfect); Map updatePerfect(Integer idArticle, String articlePerfect);
/**
* 获取公告列表
* @return
*/
List<ArticleDTO> findAnnouncements();
} }

View File

@ -76,7 +76,7 @@ public interface PortfolioService extends Service<Portfolio> {
* @param idPortfolio * @param idPortfolio
* @return * @return
*/ */
Map deletePortfolio(Integer idPortfolio); Map deletePortfolio(Integer idPortfolio) throws BaseApiException;
/** /**
* 获取作品集列表数据 * 获取作品集列表数据

View File

@ -364,6 +364,15 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
return map; return map;
} }
@Override
public List<ArticleDTO> findAnnouncements() {
List<ArticleDTO> list = articleMapper.selectAnnouncements();
list.forEach(article -> {
genArticle(article, 0);
});
return list;
}
private ArticleDTO genArticle(ArticleDTO article, Integer type) { private ArticleDTO genArticle(ArticleDTO article, Integer type) {
Integer articleList = 0; Integer articleList = 0;
Integer articleView = 1; Integer articleView = 1;

View File

@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.rymcu.forest.core.service.AbstractService; import com.rymcu.forest.core.service.AbstractService;
import com.rymcu.forest.dto.*; import com.rymcu.forest.dto.*;
import com.rymcu.forest.entity.Article;
import com.rymcu.forest.entity.Portfolio; import com.rymcu.forest.entity.Portfolio;
import com.rymcu.forest.entity.User; import com.rymcu.forest.entity.User;
import com.rymcu.forest.mapper.PortfolioMapper; import com.rymcu.forest.mapper.PortfolioMapper;
@ -152,11 +153,21 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
} }
@Override @Override
public Map deletePortfolio(Integer idPortfolio) { public Map deletePortfolio(Integer idPortfolio) throws BaseApiException {
Map map = new HashMap(1); Map map = new HashMap(1);
if (idPortfolio == null || idPortfolio.equals(0)) { if (idPortfolio == null || idPortfolio.equals(0)) {
map.put("message", "作品集数据异常"); 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); Integer articleNumber = portfolioMapper.selectCountArticleNumber(idPortfolio);
if (articleNumber > 0) { if (articleNumber > 0) {

View File

@ -123,6 +123,7 @@ public class NotificationUtils {
case "2": case "2":
// 回帖 // 回帖
comment = commentService.findById(notification.getDataId().toString()); comment = commentService.findById(notification.getDataId().toString());
if (Objects.nonNull(comment)) {
article = articleService.findArticleDTOById(comment.getCommentArticleId(), 0); article = articleService.findArticleDTOById(comment.getCommentArticleId(), 0);
if (Objects.nonNull(article)) { if (Objects.nonNull(article)) {
notificationDTO.setDataTitle(article.getArticleTitle()); notificationDTO.setDataTitle(article.getArticleTitle());
@ -130,6 +131,7 @@ public class NotificationUtils {
user = userService.findById(comment.getCommentAuthorId().toString()); user = userService.findById(comment.getCommentAuthorId().toString());
notificationDTO.setAuthor(genAuthor(user)); notificationDTO.setAuthor(genAuthor(user));
} }
}
break; break;
case "3": case "3":
// 关注用户发布文章 // 关注用户发布文章

View File

@ -97,6 +97,16 @@ public class CommonApiController {
return GlobalResultGenerator.genSuccessResult(map); return GlobalResultGenerator.genSuccessResult(map);
} }
@GetMapping("/announcements")
@VisitLogger
public GlobalResult<Map> announcements(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "5") Integer rows){
PageHelper.startPage(page, rows);
List<ArticleDTO> list = articleService.findAnnouncements();
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
Map map = Utils.getArticlesGlobalResult(pageInfo);
return GlobalResultGenerator.genSuccessResult(map);
}
@GetMapping("/article/{id}") @GetMapping("/article/{id}")
@VisitLogger @VisitLogger
public GlobalResult<Map<String, Object>> article(@PathVariable Integer id){ public GlobalResult<Map<String, Object>> article(@PathVariable Integer id){

View File

@ -68,7 +68,7 @@ public class PortfolioController {
} }
@DeleteMapping("/delete") @DeleteMapping("/delete")
public GlobalResult delete(Integer idPortfolio){ public GlobalResult delete(Integer idPortfolio) throws BaseApiException {
Map map = portfolioService.deletePortfolio(idPortfolio); Map map = portfolioService.deletePortfolio(idPortfolio);
return GlobalResultGenerator.genSuccessResult(map); return GlobalResultGenerator.genSuccessResult(map);
} }

View File

@ -105,6 +105,7 @@
where article_status = 0 where article_status = 0
<if test="topicUri != 'news'"> <if test="topicUri != 'news'">
and FIND_IN_SET('划水',art.article_tags) = 0 and FIND_IN_SET('划水',art.article_tags) = 0
and FIND_IN_SET('公告',art.article_tags) = 0
</if> </if>
order by updated_time desc order by updated_time desc
</select> </select>
@ -155,4 +156,10 @@
select va.article_title, va.id, va.article_permalink from forest_portfolio_article vpa 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 join forest_article va on va.id = vpa.id_article where va.article_status = '0' and id_portfolio = #{idPortfolio} order by sort_no
</select> </select>
<select id="selectAnnouncements" resultMap="DTOResultMap">
select art.*,su.nickname,su.avatar_url from forest_article art join forest_user su on art.article_author_id = su.id
where article_status = 0
and FIND_IN_SET('公告',art.article_tags) > 0
order by updated_time desc
</select>
</mapper> </mapper>