diff --git a/src/main/java/com/yaoyuan/jiscuss/service/impl/PostsServiceImpl.java b/src/main/java/com/yaoyuan/jiscuss/service/impl/PostsServiceImpl.java index dcd4672..bbe4582 100644 --- a/src/main/java/com/yaoyuan/jiscuss/service/impl/PostsServiceImpl.java +++ b/src/main/java/com/yaoyuan/jiscuss/service/impl/PostsServiceImpl.java @@ -17,10 +17,10 @@ import java.util.List; import java.util.Map; import java.util.Optional; - @Service @Transactional public class PostsServiceImpl implements IPostsService { + @Autowired private PostsRepository postsRepository; @@ -31,7 +31,6 @@ public class PostsServiceImpl implements IPostsService { @Override public List findOneBy(Integer id) { - List posts = postsRepository.findOneBy(id); return posts; } @@ -49,19 +48,14 @@ public class PostsServiceImpl implements IPostsService { public List findPostCustomById(Integer id) { //查询id为1且parentId为null的评论 List> firstposts = postsRepository.findAllByDIdAndparentIdNull(id); - List firstpostCustomList = PostCommonUtil.getNewPostsObjMap(firstposts); - // List firstpostCustomListNew = PostCommonUtil.getNewPostsObjCustom(firstpostCustomList); //查询id为1且parentId不为null的评论 List> thenposts = postsRepository.findAllByDIdAndparentIdNotNull(id); - List thenpostCustomList = PostCommonUtil.getNewPostsObjMap(thenposts); // List thenpostCustomListNew = PostCommonUtil.getNewPostsObjCustom(thenpostCustomList); - - //新建一个Node集合。 ArrayList nodes = new ArrayList<>(); //将第一层评论都添加都Node集合中 @@ -76,17 +70,12 @@ public class PostsServiceImpl implements IPostsService { //打印回复链表 Node.show(list); - // List> posts = postsRepository.findPostCustomById(id); -// // List postCustomList = PostCommonUtil.getNewPostsObjMap(posts); -// // List postCustomListNew = PostCommonUtil.getNewPostsObjCustom(postCustomList); - return list; } - @Override public Post insert(Post post) { return postsRepository.save(post);