pull/1220/head
Ryan Wang 2020-12-25 22:02:50 +08:00 committed by GitHub
parent 913bc6042e
commit 276aea4bdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -8,10 +8,10 @@ import org.springframework.data.web.PageableDefault;
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;
@ -56,12 +56,12 @@ public class CategoryController {
@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);
}
}

View File

@ -9,10 +9,10 @@ import org.springframework.data.web.PageableDefault;
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;
@ -59,13 +59,13 @@ public class TagController {
@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);
}
}