diff --git a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java index ea40f7f..60aa8c2 100644 --- a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java @@ -41,6 +41,8 @@ public class ArticleDTO { private String articlePermalink; /** 站内链接 */ private String articleLink; + /** 文章状态 */ + private String articleStatus; /** 更新时间 */ private Date updatedTime; diff --git a/src/main/java/com/rymcu/vertical/entity/Article.java b/src/main/java/com/rymcu/vertical/entity/Article.java index e389d2c..6aefb49 100644 --- a/src/main/java/com/rymcu/vertical/entity/Article.java +++ b/src/main/java/com/rymcu/vertical/entity/Article.java @@ -46,4 +46,6 @@ public class Article implements Serializable,Cloneable { private Date createdTime; /** 更新时间 */ private Date updatedTime; + /** 文章状态 */ + private String articleStatus; } diff --git a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java index 71b036c..05bc666 100644 --- a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java @@ -10,34 +10,105 @@ import org.apache.ibatis.annotations.Param; import java.util.List; +/** + * @author ronger + */ public interface ArticleMapper extends Mapper
{ + + /** + * 获取文章列表 + * @param searchText + * @param tag + * @return + */ List selectArticles(@Param("searchText") String searchText, @Param("tag") String tag); + /** + * 根据用户 ID 获取作者信息 + * @param id + * @return + */ Author selectAuthor(@Param("id") Integer id); + /** + * 根据文章 ID 查询文章 + * @param id + * @return + */ ArticleDTO selectArticleDTOById(@Param("id") Integer id); + /** + * 保存文章内容 + * @param idArticle + * @param articleContent + * @param articleContentHtml + * @return + */ Integer insertArticleContent(@Param("idArticle") Integer idArticle, @Param("articleContent") String articleContent, @Param("articleContentHtml") String articleContentHtml); + /** + * 更新文章内容 + * @param idArticle + * @param articleContent + * @param articleContentHtml + * @return + */ Integer updateArticleContent(@Param("idArticle") Integer idArticle, @Param("articleContent") String articleContent, @Param("articleContentHtml") String articleContentHtml); + /** + * 获取文章正文内容 + * @param idArticle + * @return + */ ArticleContent selectArticleContent(@Param("idArticle") Integer idArticle); + /** + * 获取主题下文章列表 + * @param topicName + * @return + */ List selectArticlesByTopicUri(@Param("topicName") String topicName); + /** + * 获取标签下文章列表 + * @param tagName + * @return + */ List selectArticlesByTagName(@Param("tagName") String tagName); + /** + * 获取用户文章列表 + * @param idUser + * @return + */ List selectUserArticles(@Param("idUser") Integer idUser); + /** + * 删除文章标签 + * @param id + * @return + */ Integer deleteTagArticle(@Param("id") Integer id); + /** + * 获取文章标签列表 + * @param idArticle + * @return + */ List selectTags(@Param("idArticle") Integer idArticle); /** - * + * 更新文章浏览数 * @param id * @param articleViewCount * @return */ Integer updateArticleViewCount(@Param("id") Integer id, @Param("articleViewCount") Integer articleViewCount); + + /** + * 获取草稿列表 + * @param idUser + * @return + */ + List selectDrafts(@Param("idUser") Integer idUser); } diff --git a/src/main/java/com/rymcu/vertical/service/ArticleService.java b/src/main/java/com/rymcu/vertical/service/ArticleService.java index a901362..48ff943 100644 --- a/src/main/java/com/rymcu/vertical/service/ArticleService.java +++ b/src/main/java/com/rymcu/vertical/service/ArticleService.java @@ -74,4 +74,10 @@ public interface ArticleService extends Service
{ * @param id */ void incrementArticleViewCount(Integer id); + + /** + * 查询草稿文章类别 + * @return + */ + List findDrafts() throws BaseApiException; } diff --git a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java index 4b7ada1..4ca16f9 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -127,6 +127,7 @@ public class ArticleServiceImpl extends AbstractService
implements Arti newArticle.setArticleTags(articleTags); newArticle.setCreatedTime(new Date()); newArticle.setUpdatedTime(newArticle.getCreatedTime()); + newArticle.setArticleStatus(article.getArticleStatus()); articleMapper.insertSelective(newArticle); newArticle.setArticlePermalink(domain + "/article/"+newArticle.getIdArticle()); newArticle.setArticleLink("/article/"+newArticle.getIdArticle()); @@ -226,6 +227,16 @@ public class ArticleServiceImpl extends AbstractService
implements Arti articleMapper.updateArticleViewCount(article.getIdArticle(), articleViewCount); } + @Override + public List findDrafts() throws BaseApiException { + User user = UserUtils.getWxCurrentUser(); + List list = articleMapper.selectDrafts(user.getIdUser()); + list.forEach(article->{ + genArticle(article,0); + }); + return list; + } + private ArticleDTO genArticle(ArticleDTO article,Integer type) { Author author = articleMapper.selectAuthor(article.getArticleAuthorId()); article.setArticleAuthor(author); diff --git a/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java index b9b3c88..f7268e1 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/CommentServiceImpl.java @@ -20,6 +20,9 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.*; +/** + * @author ronger + */ @Service public class CommentServiceImpl extends AbstractService implements CommentService { diff --git a/src/main/java/com/rymcu/vertical/web/api/article/ArticleController.java b/src/main/java/com/rymcu/vertical/web/api/article/ArticleController.java index 5874af4..d3e6b91 100644 --- a/src/main/java/com/rymcu/vertical/web/api/article/ArticleController.java +++ b/src/main/java/com/rymcu/vertical/web/api/article/ArticleController.java @@ -1,11 +1,14 @@ package com.rymcu.vertical.web.api.article; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.rymcu.vertical.core.result.GlobalResult; import com.rymcu.vertical.core.result.GlobalResultGenerator; import com.rymcu.vertical.dto.ArticleDTO; import com.rymcu.vertical.dto.CommentDTO; import com.rymcu.vertical.service.ArticleService; import com.rymcu.vertical.service.CommentService; +import com.rymcu.vertical.util.Utils; import com.rymcu.vertical.web.api.exception.BaseApiException; import org.springframework.web.bind.annotation.*; @@ -64,4 +67,13 @@ public class ArticleController { return GlobalResultGenerator.genSuccessResult(map); } + @GetMapping("/drafts") + public GlobalResult drafts(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException { + PageHelper.startPage(page, rows); + List list = articleService.findDrafts(); + PageInfo pageInfo = new PageInfo(list); + Map map = Utils.getArticlesGlobalResult(pageInfo); + return GlobalResultGenerator.genSuccessResult(map); + } + } diff --git a/src/main/java/mapper/ArticleMapper.xml b/src/main/java/mapper/ArticleMapper.xml index 65d0423..49335d9 100644 --- a/src/main/java/mapper/ArticleMapper.xml +++ b/src/main/java/mapper/ArticleMapper.xml @@ -35,6 +35,7 @@ + @@ -70,7 +71,7 @@ delete from vertical_tag_article where id_article = #{id} select vt.id, vt.tag_title, vt.tag_icon_path, vt.tag_uri, vt.tag_description from vertical_tag vt left join vertical_tag_article vta on vt.id = vta.id_tag where vta.id_article = #{idArticle} + \ No newline at end of file