✨ 文章优选功能
This commit is contained in:
parent
59992dcd53
commit
1ef5f5c898
@ -53,4 +53,6 @@ public class ArticleDTO {
|
|||||||
private List<PortfolioArticleDTO> portfolios;
|
private List<PortfolioArticleDTO> portfolios;
|
||||||
|
|
||||||
private Integer sortNo;
|
private Integer sortNo;
|
||||||
|
/** 0:非优选1:优选;0 */
|
||||||
|
private String articlePerfect;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public class Article implements Serializable,Cloneable {
|
|||||||
private String articlePreviewContent;
|
private String articlePreviewContent;
|
||||||
/** 评论总数 */
|
/** 评论总数 */
|
||||||
private Integer articleCommentCount;
|
private Integer articleCommentCount;
|
||||||
/** 0:非优选1:优选;0 */
|
/** 0:非优选1:优选; */
|
||||||
private String articlePerfect;
|
private String articlePerfect;
|
||||||
/** 文章永久链接 */
|
/** 文章永久链接 */
|
||||||
private String articlePermalink;
|
private String articlePermalink;
|
||||||
|
@ -176,4 +176,12 @@ public interface ArticleMapper extends Mapper<Article> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ArticleDTO> selectPortfolioArticlesByIdPortfolioAndSortNo(@Param("idPortfolio") Integer idPortfolio, @Param("sortNo") Integer sortNo);
|
List<ArticleDTO> selectPortfolioArticlesByIdPortfolioAndSortNo(@Param("idPortfolio") Integer idPortfolio, @Param("sortNo") Integer sortNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新文章优选状态
|
||||||
|
* @param idArticle
|
||||||
|
* @param articlePerfect
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updatePerfect(@Param("idArticle") Integer idArticle, @Param("articlePerfect") String articlePerfect);
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,16 @@ public interface ArticleService extends Service<Article> {
|
|||||||
* @param idArticle
|
* @param idArticle
|
||||||
* @param tags
|
* @param tags
|
||||||
* @return
|
* @return
|
||||||
|
* @throws UnsupportedEncodingException
|
||||||
|
* @throws BaseApiException
|
||||||
*/
|
*/
|
||||||
Map updateTags(Integer idArticle, String tags) throws UnsupportedEncodingException, BaseApiException;
|
Map updateTags(Integer idArticle, String tags) throws UnsupportedEncodingException, BaseApiException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新文章优选状态
|
||||||
|
* @param idArticle
|
||||||
|
* @param articlePerfect
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map updatePerfect(Integer idArticle, String articlePerfect);
|
||||||
}
|
}
|
||||||
|
@ -334,24 +334,37 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map updatePerfect(Integer idArticle, String articlePerfect) {
|
||||||
|
Map map = new HashMap(2);
|
||||||
|
int result = articleMapper.updatePerfect(idArticle, articlePerfect);
|
||||||
|
if (result == 0) {
|
||||||
|
map.put("success", false);
|
||||||
|
map.put("message", "设置优选文章失败!");
|
||||||
|
} else {
|
||||||
|
map.put("success", true);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
private ArticleDTO genArticle(ArticleDTO article, Integer type) {
|
private ArticleDTO genArticle(ArticleDTO article, Integer type) {
|
||||||
Integer ARTICLE_LIST = 0;
|
Integer articleList = 0;
|
||||||
Integer ARTICLE_VIEW = 1;
|
Integer articleView = 1;
|
||||||
Integer ARTICLE_EDIT = 2;
|
Integer articleEdit = 2;
|
||||||
Author author = genAuthor(article);
|
Author author = genAuthor(article);
|
||||||
article.setArticleAuthor(author);
|
article.setArticleAuthor(author);
|
||||||
article.setTimeAgo(Utils.getTimeAgo(article.getUpdatedTime()));
|
article.setTimeAgo(Utils.getTimeAgo(article.getUpdatedTime()));
|
||||||
List<ArticleTagDTO> tags = articleMapper.selectTags(article.getIdArticle());
|
List<ArticleTagDTO> tags = articleMapper.selectTags(article.getIdArticle());
|
||||||
article.setTags(tags);
|
article.setTags(tags);
|
||||||
if (!type.equals(ARTICLE_LIST)) {
|
if (!type.equals(articleList)) {
|
||||||
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
|
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
|
||||||
if (type.equals(ARTICLE_VIEW)) {
|
if (type.equals(articleView)) {
|
||||||
article.setArticleContent(articleContent.getArticleContentHtml());
|
article.setArticleContent(articleContent.getArticleContentHtml());
|
||||||
// 获取所属作品集列表数据
|
// 获取所属作品集列表数据
|
||||||
List<PortfolioArticleDTO> portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle());
|
List<PortfolioArticleDTO> portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle());
|
||||||
portfolioArticleDTOList.forEach(portfolioArticleDTO -> genPortfolioArticles(portfolioArticleDTO));
|
portfolioArticleDTOList.forEach(portfolioArticleDTO -> genPortfolioArticles(portfolioArticleDTO));
|
||||||
article.setPortfolios(portfolioArticleDTOList);
|
article.setPortfolios(portfolioArticleDTOList);
|
||||||
} else if (type.equals(ARTICLE_EDIT)) {
|
} else if (type.equals(articleEdit)) {
|
||||||
article.setArticleContent(articleContent.getArticleContent());
|
article.setArticleContent(articleContent.getArticleContent());
|
||||||
} else {
|
} else {
|
||||||
article.setArticleContent(articleContent.getArticleContentHtml());
|
article.setArticleContent(articleContent.getArticleContentHtml());
|
||||||
|
@ -87,4 +87,10 @@ public class ArticleController {
|
|||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PatchMapping("/update-perfect")
|
||||||
|
public GlobalResult updatePerfect(@RequestBody Article article) {
|
||||||
|
Map map = articleService.updatePerfect(article.getIdArticle(), article.getArticlePerfect());
|
||||||
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<result column="article_status" property="articleStatus"></result>
|
<result column="article_status" property="articleStatus"></result>
|
||||||
<result column="updated_time" property="updatedTime"></result>
|
<result column="updated_time" property="updatedTime"></result>
|
||||||
<result column="sort_no" property="sortNo"></result>
|
<result column="sort_no" property="sortNo"></result>
|
||||||
|
<result column="article_perfect" property="articlePerfect"></result>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<resultMap id="ArticleContentResultMap" type="com.rymcu.forest.entity.ArticleContent">
|
<resultMap id="ArticleContentResultMap" type="com.rymcu.forest.entity.ArticleContent">
|
||||||
<result column="id_article" property="idArticle"/>
|
<result column="id_article" property="idArticle"/>
|
||||||
@ -78,6 +79,9 @@
|
|||||||
<update id="updateArticleLinkAndPreviewContent">
|
<update id="updateArticleLinkAndPreviewContent">
|
||||||
update vertical_article set article_link = #{articleLink}, article_permalink = #{articlePermalink}, article_preview_content = #{articlePreviewContent} where id = #{idArticle}
|
update vertical_article set article_link = #{articleLink}, article_permalink = #{articlePermalink}, article_preview_content = #{articlePreviewContent} where id = #{idArticle}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updatePerfect">
|
||||||
|
update vertical_article set article_perfect = #{articlePerfect} where id = #{idArticle}
|
||||||
|
</update>
|
||||||
<delete id="deleteTagArticle">
|
<delete id="deleteTagArticle">
|
||||||
delete from vertical_tag_article where id_article = #{id}
|
delete from vertical_tag_article where id_article = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
Loading…
Reference in New Issue
Block a user