diff --git a/src/main/java/cn/celess/blog/mapper/ArticleTagMapper.java b/src/main/java/cn/celess/blog/mapper/ArticleTagMapper.java index bcf4fc7..5620e8f 100644 --- a/src/main/java/cn/celess/blog/mapper/ArticleTagMapper.java +++ b/src/main/java/cn/celess/blog/mapper/ArticleTagMapper.java @@ -1,6 +1,7 @@ package cn.celess.blog.mapper; import cn.celess.blog.entity.ArticleTag; +import cn.celess.blog.entity.Tag; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; @@ -27,6 +28,8 @@ public interface ArticleTagMapper { List findAllByArticleId(Long articleId); + List findTagByArticleId(Long articleId); + int deleteMultiById(List articleTags); List findArticleByTag(Long tagId); diff --git a/src/main/resources/mapper/ArticleTagMapper.xml b/src/main/resources/mapper/ArticleTagMapper.xml index 38f4ba6..bfd0c46 100644 --- a/src/main/resources/mapper/ArticleTagMapper.xml +++ b/src/main/resources/mapper/ArticleTagMapper.xml @@ -64,6 +64,14 @@ and article_tag.t_id = tag_category.t_id + + - \ No newline at end of file + diff --git a/src/main/resources/mapper/articleMapper.xml b/src/main/resources/mapper/articleMapper.xml index 6e9928d..2a3ee0d 100644 --- a/src/main/resources/mapper/articleMapper.xml +++ b/src/main/resources/mapper/articleMapper.xml @@ -1,185 +1,187 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - insert into article (a_author_id, a_category_id, a_md_content, a_is_original, - a_summary, a_title, a_url) - values (#{user.id}, #{category.id}, #{mdContent}, #{type}, #{summary}, #{title}, #{url}) - - - update article - set is_delete = true - where a_id = #{id} - - - - update article - set a_update_date=now(), - a_title=#{title}, - a_md_content=#{mdContent}, - a_summary=#{summary}, - a_is_original=#{type}, - a_url=#{url}, - a_category_id=#{category.id}, - a_is_open=#{open} - where a_id = #{id} - - - - update article - set a_reading_number=a_reading_number + 1 - where a_id = #{id} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into article (a_author_id, a_category_id, a_md_content, a_is_original, + a_summary, a_title, a_url) + values (#{user.id}, #{category.id}, #{mdContent}, #{type}, #{summary}, #{title}, #{url}) + + + update article + set is_delete = true + where a_id = #{id} + + + + update article + set a_update_date=now(), + a_title=#{title}, + a_md_content=#{mdContent}, + a_summary=#{summary}, + a_is_original=#{type}, + a_url=#{url}, + a_category_id=#{category.id}, + a_is_open=#{open} + where a_id = #{id} + + + + update article + set a_reading_number=a_reading_number + 1 + where a_id = #{id} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/cn/celess/blog/mapper/ArticleTagMapperTest.java b/src/test/java/cn/celess/blog/mapper/ArticleTagMapperTest.java index 6941f2d..457f760 100644 --- a/src/test/java/cn/celess/blog/mapper/ArticleTagMapperTest.java +++ b/src/test/java/cn/celess/blog/mapper/ArticleTagMapperTest.java @@ -134,4 +134,13 @@ public class ArticleTagMapperTest extends BaseTest { return articleTag; } -} \ No newline at end of file + + @Test + public void findTagByArticleId() { + Article article = articleMapper.findAll().get(0); + assertNotNull(article); + + List tagByArticleId = articleTagMapper.findTagByArticleId(article.getId()); + assertNotEquals(0, tagByArticleId.size()); + } +} diff --git a/src/test/java/cn/celess/blog/service/ArticleServiceTest.java b/src/test/java/cn/celess/blog/service/ArticleServiceTest.java index b32c223..b0ea6e5 100644 --- a/src/test/java/cn/celess/blog/service/ArticleServiceTest.java +++ b/src/test/java/cn/celess/blog/service/ArticleServiceTest.java @@ -3,6 +3,7 @@ package cn.celess.blog.service; import cn.celess.blog.BaseTest; import cn.celess.blog.entity.model.ArticleModel; import cn.celess.blog.entity.model.PageData; +import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -24,4 +25,13 @@ public class ArticleServiceTest extends BaseTest { assertTrue(pageData.getList().stream().anyMatch(ArticleModel::isDeleted)); assertTrue(pageData.getList().stream().anyMatch(articleModel -> !articleModel.isDeleted())); } -} \ No newline at end of file + + @Test + public void retrievePageForOpen() { + PageData articleModelPageData = articleService.retrievePageForOpen(10, 1); + assertEquals(10, articleModelPageData.getPageSize()); + assertEquals(1, articleModelPageData.getPageNum()); + assertEquals(10, articleModelPageData.getList().size()); + articleModelPageData.getList().forEach(Assert::assertNotNull); + } +}