💩 公告组件 API

This commit is contained in:
ronger 2021-05-07 08:27:36 +08:00
parent fe61bf1945
commit baa49a22e4
6 changed files with 42 additions and 0 deletions

View File

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

View File

@ -190,4 +190,10 @@ public interface ArticleMapper extends Mapper<Article> {
* @param 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
* @return
* @throws BaseApiException
* */
Map delete(Integer id) throws BaseApiException;
@ -123,4 +124,10 @@ public interface ArticleService extends Service<Article> {
* @return
*/
Map updatePerfect(Integer idArticle, String articlePerfect);
/**
* 获取公告列表
* @return
*/
List<ArticleDTO> findAnnouncements();
}

View File

@ -364,6 +364,15 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
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) {
Integer articleList = 0;
Integer articleView = 1;

View File

@ -97,6 +97,16 @@ public class CommonApiController {
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}")
@VisitLogger
public GlobalResult<Map<String, Object>> article(@PathVariable Integer id){

View File

@ -105,6 +105,7 @@
where article_status = 0
<if test="topicUri != 'news'">
and FIND_IN_SET('划水',art.article_tags) = 0
and FIND_IN_SET('公告',art.article_tags) = 0
</if>
order by updated_time desc
</select>
@ -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
</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>