调整数据库字段,优化部分接口 #1
@@ -1,7 +1,5 @@
|
||||
package cn.celess.blog.enmu;
|
||||
|
||||
import com.sun.javaws.jnl.IconDesc;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-25 08:58
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.celess.blog.entity;
|
||||
|
||||
import com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -281,7 +281,8 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
PageData<ArticleModel> pageData = new PageData<ArticleModel>(new PageInfo<Article>(articleList));
|
||||
List<ArticleModel> articleModelList = new ArrayList<>();
|
||||
articleList.forEach(article -> {
|
||||
ArticleModel articleModel = ModalTrans.article(article, true);
|
||||
ArticleModel articleModel = ModalTrans.article(article);
|
||||
articleModel.setMdContent(null);
|
||||
articleModelList.add(articleModel);
|
||||
});
|
||||
pageData.setList(articleModelList);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ModalTrans {
|
||||
|
||||
public static ArticleModel article(Article article, boolean noMdContent) {
|
||||
ArticleModel article1 = article(article);
|
||||
if (!noMdContent) {
|
||||
if (!noMdContent || article1 == null) {
|
||||
return article1;
|
||||
}
|
||||
article1.setMdContent(null);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
t_id = #{tag.id},
|
||||
</if>
|
||||
</set>
|
||||
where at_id = #{tag.id}
|
||||
where at_id = #{id}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
@@ -69,7 +69,8 @@
|
||||
from article_tag,
|
||||
article,
|
||||
tag_category
|
||||
where article_tag.a_id = article.a_id
|
||||
where article_tag.at_id = #{id}
|
||||
and article_tag.a_id = article.a_id
|
||||
and tag_category.t_id = article_tag.t_id
|
||||
</select>
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ArticleMapperTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void findAllByCategoryIdAndOpen() {
|
||||
List<Article> allByCategoryId = articleMapper.findAllByCategoryId(1);
|
||||
List<Article> allByCategoryId = articleMapper.findAllByCategoryIdAndOpen(1);
|
||||
assertNotEquals(0, allByCategoryId.size());
|
||||
allByCategoryId.forEach(article -> assertTrue(article.getOpen()));
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ArticleTagMapperTest extends BaseTest {
|
||||
@Test
|
||||
public void findArticleByTagAndOpen() {
|
||||
ArticleTag articleTag = generateArticle();
|
||||
List<ArticleTag> articleByTag = articleTagMapper.findArticleByTag(21L);
|
||||
List<ArticleTag> articleByTag = articleTagMapper.findArticleByTagAndOpen(21L);
|
||||
assertNotEquals(0, articleByTag.size());
|
||||
articleByTag.forEach(articleTag1 -> assertEquals(articleTag.getTag().getName(), articleTag1.getTag().getName()));
|
||||
articleByTag.forEach(articleTag1 -> assertTrue(articleTag1.getArticle().getOpen()));
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -106,7 +107,8 @@ public class CategoryMapperTest extends BaseTest {
|
||||
@Test
|
||||
public void count() {
|
||||
List<Category> all = categoryMapper.findAll();
|
||||
assertEquals(all.size(), categoryMapper.count());
|
||||
List<Category> collect = all.stream().filter(category -> !category.isDeleted()).collect(Collectors.toList());
|
||||
assertEquals(collect.size(), categoryMapper.count());
|
||||
}
|
||||
|
||||
private Category generateCategory() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -79,7 +80,8 @@ public class TagMapperTest extends BaseTest {
|
||||
public void count() {
|
||||
assertNotEquals(0, tagMapper.count());
|
||||
List<Tag> all = tagMapper.findAll();
|
||||
assertEquals(all.size(), tagMapper.count());
|
||||
List<Tag> collect = all.stream().filter(tag -> !tag.isDeleted()).collect(Collectors.toList());
|
||||
assertEquals(collect.size(), tagMapper.count());
|
||||
}
|
||||
|
||||
private Tag generateTag() {
|
||||
|
||||
Reference in New Issue
Block a user