Skip to content

Commit

Permalink
feat: #766 (#1210)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby authored Dec 25, 2020
1 parent 913bc60 commit 276aea4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.CategoryDTO;
import run.halo.app.model.dto.post.BasePostSimpleDTO;
import run.halo.app.model.entity.Category;
import run.halo.app.model.entity.Post;
import run.halo.app.model.enums.PostStatus;
import run.halo.app.model.vo.PostListVO;
import run.halo.app.service.CategoryService;
import run.halo.app.service.PostCategoryService;
import run.halo.app.service.PostService;
Expand Down Expand Up @@ -56,12 +56,12 @@ public List<? extends CategoryDTO> listCategories(@SortDefault(sort = "updateTim

@GetMapping("{slug}/posts")
@ApiOperation("Lists posts by category slug")
public Page<BasePostSimpleDTO> listPostsBy(@PathVariable("slug") String slug,
public Page<PostListVO> listPostsBy(@PathVariable("slug") String slug,
@PageableDefault(sort = {"topPriority", "updateTime"}, direction = DESC) Pageable pageable) {
// Get category by slug
Category category = categoryService.getBySlugOfNonNull(slug);

Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), PostStatus.PUBLISHED, pageable);
return postService.convertToSimple(postPage);
return postService.convertToListVo(postPage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.TagDTO;
import run.halo.app.model.dto.post.BasePostSimpleDTO;
import run.halo.app.model.entity.Post;
import run.halo.app.model.entity.Tag;
import run.halo.app.model.enums.PostStatus;
import run.halo.app.model.vo.PostListVO;
import run.halo.app.service.PostService;
import run.halo.app.service.PostTagService;
import run.halo.app.service.TagService;
Expand Down Expand Up @@ -59,13 +59,13 @@ public List<? extends TagDTO> listTags(@SortDefault(sort = "updateTime", directi

@GetMapping("{slug}/posts")
@ApiOperation("Lists posts by tag slug")
public Page<BasePostSimpleDTO> listPostsBy(@PathVariable("slug") String slug,
public Page<PostListVO> listPostsBy(@PathVariable("slug") String slug,
@PageableDefault(sort = {"topPriority", "updateTime"}, direction = DESC) Pageable pageable) {
// Get tag by slug
Tag tag = tagService.getBySlugOfNonNull(slug);

// Get posts, convert and return
Page<Post> postPage = postTagService.pagePostsBy(tag.getId(), PostStatus.PUBLISHED, pageable);
return postService.convertToSimple(postPage);
return postService.convertToListVo(postPage);
}
}

0 comments on commit 276aea4

Please sign in to comment.