mirror of https://github.com/halo-dev/halo
parent
913bc6042e
commit
276aea4bdd
|
@ -8,10 +8,10 @@ import org.springframework.data.web.PageableDefault;
|
||||||
import org.springframework.data.web.SortDefault;
|
import org.springframework.data.web.SortDefault;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import run.halo.app.model.dto.CategoryDTO;
|
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.Category;
|
||||||
import run.halo.app.model.entity.Post;
|
import run.halo.app.model.entity.Post;
|
||||||
import run.halo.app.model.enums.PostStatus;
|
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.CategoryService;
|
||||||
import run.halo.app.service.PostCategoryService;
|
import run.halo.app.service.PostCategoryService;
|
||||||
import run.halo.app.service.PostService;
|
import run.halo.app.service.PostService;
|
||||||
|
@ -56,12 +56,12 @@ public class CategoryController {
|
||||||
|
|
||||||
@GetMapping("{slug}/posts")
|
@GetMapping("{slug}/posts")
|
||||||
@ApiOperation("Lists posts by category slug")
|
@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) {
|
@PageableDefault(sort = {"topPriority", "updateTime"}, direction = DESC) Pageable pageable) {
|
||||||
// Get category by slug
|
// Get category by slug
|
||||||
Category category = categoryService.getBySlugOfNonNull(slug);
|
Category category = categoryService.getBySlugOfNonNull(slug);
|
||||||
|
|
||||||
Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), PostStatus.PUBLISHED, pageable);
|
Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), PostStatus.PUBLISHED, pageable);
|
||||||
return postService.convertToSimple(postPage);
|
return postService.convertToListVo(postPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ import org.springframework.data.web.PageableDefault;
|
||||||
import org.springframework.data.web.SortDefault;
|
import org.springframework.data.web.SortDefault;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import run.halo.app.model.dto.TagDTO;
|
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.Post;
|
||||||
import run.halo.app.model.entity.Tag;
|
import run.halo.app.model.entity.Tag;
|
||||||
import run.halo.app.model.enums.PostStatus;
|
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.PostService;
|
||||||
import run.halo.app.service.PostTagService;
|
import run.halo.app.service.PostTagService;
|
||||||
import run.halo.app.service.TagService;
|
import run.halo.app.service.TagService;
|
||||||
|
@ -59,13 +59,13 @@ public class TagController {
|
||||||
|
|
||||||
@GetMapping("{slug}/posts")
|
@GetMapping("{slug}/posts")
|
||||||
@ApiOperation("Lists posts by tag slug")
|
@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) {
|
@PageableDefault(sort = {"topPriority", "updateTime"}, direction = DESC) Pageable pageable) {
|
||||||
// Get tag by slug
|
// Get tag by slug
|
||||||
Tag tag = tagService.getBySlugOfNonNull(slug);
|
Tag tag = tagService.getBySlugOfNonNull(slug);
|
||||||
|
|
||||||
// Get posts, convert and return
|
// Get posts, convert and return
|
||||||
Page<Post> postPage = postTagService.pagePostsBy(tag.getId(), PostStatus.PUBLISHED, pageable);
|
Page<Post> postPage = postTagService.pagePostsBy(tag.getId(), PostStatus.PUBLISHED, pageable);
|
||||||
return postService.convertToSimple(postPage);
|
return postService.convertToListVo(postPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue