mirror of https://github.com/halo-dev/halo
refactor: content api.
parent
f99daee263
commit
04512db9ba
|
@ -16,10 +16,7 @@ import run.halo.app.model.entity.PostComment;
|
||||||
import run.halo.app.model.enums.CommentStatus;
|
import run.halo.app.model.enums.CommentStatus;
|
||||||
import run.halo.app.model.enums.PostStatus;
|
import run.halo.app.model.enums.PostStatus;
|
||||||
import run.halo.app.model.params.PostCommentParam;
|
import run.halo.app.model.params.PostCommentParam;
|
||||||
import run.halo.app.model.vo.BaseCommentVO;
|
import run.halo.app.model.vo.*;
|
||||||
import run.halo.app.model.vo.BaseCommentWithParentVO;
|
|
||||||
import run.halo.app.model.vo.CommentWithHasChildrenVO;
|
|
||||||
import run.halo.app.model.vo.PostDetailVO;
|
|
||||||
import run.halo.app.service.OptionService;
|
import run.halo.app.service.OptionService;
|
||||||
import run.halo.app.service.PostCommentService;
|
import run.halo.app.service.PostCommentService;
|
||||||
import run.halo.app.service.PostService;
|
import run.halo.app.service.PostService;
|
||||||
|
@ -54,9 +51,9 @@ public class PostController {
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("Lists posts")
|
@ApiOperation("Lists posts")
|
||||||
public Page<BasePostSimpleDTO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable) {
|
public Page<PostListVO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable) {
|
||||||
Page<Post> postPage = postService.pageBy(PostStatus.PUBLISHED, pageable);
|
Page<Post> postPage = postService.pageBy(PostStatus.PUBLISHED, pageable);
|
||||||
return postService.convertToSimple(postPage);
|
return postService.convertToListVo(postPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "search")
|
@PostMapping(value = "search")
|
||||||
|
|
|
@ -10,16 +10,12 @@ import org.springframework.data.web.SortDefault;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import run.halo.app.cache.lock.CacheLock;
|
import run.halo.app.cache.lock.CacheLock;
|
||||||
import run.halo.app.model.dto.BaseCommentDTO;
|
import run.halo.app.model.dto.BaseCommentDTO;
|
||||||
import run.halo.app.model.dto.post.BasePostDetailDTO;
|
|
||||||
import run.halo.app.model.dto.post.BasePostSimpleDTO;
|
|
||||||
import run.halo.app.model.entity.Sheet;
|
import run.halo.app.model.entity.Sheet;
|
||||||
import run.halo.app.model.entity.SheetComment;
|
import run.halo.app.model.entity.SheetComment;
|
||||||
import run.halo.app.model.enums.CommentStatus;
|
import run.halo.app.model.enums.CommentStatus;
|
||||||
import run.halo.app.model.enums.PostStatus;
|
import run.halo.app.model.enums.PostStatus;
|
||||||
import run.halo.app.model.params.SheetCommentParam;
|
import run.halo.app.model.params.SheetCommentParam;
|
||||||
import run.halo.app.model.vo.BaseCommentVO;
|
import run.halo.app.model.vo.*;
|
||||||
import run.halo.app.model.vo.BaseCommentWithParentVO;
|
|
||||||
import run.halo.app.model.vo.CommentWithHasChildrenVO;
|
|
||||||
import run.halo.app.service.OptionService;
|
import run.halo.app.service.OptionService;
|
||||||
import run.halo.app.service.SheetCommentService;
|
import run.halo.app.service.SheetCommentService;
|
||||||
import run.halo.app.service.SheetService;
|
import run.halo.app.service.SheetService;
|
||||||
|
@ -53,17 +49,17 @@ public class SheetController {
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("Lists sheets")
|
@ApiOperation("Lists sheets")
|
||||||
public Page<BasePostSimpleDTO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable) {
|
public Page<SheetListVO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable) {
|
||||||
Page<Sheet> sheetPage = sheetService.pageBy(PostStatus.PUBLISHED, pageable);
|
Page<Sheet> sheetPage = sheetService.pageBy(PostStatus.PUBLISHED, pageable);
|
||||||
return sheetService.convertToSimple(sheetPage);
|
return sheetService.convertToListVo(sheetPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{sheetId:\\d+}")
|
@GetMapping("{sheetId:\\d+}")
|
||||||
@ApiOperation("Gets a sheet")
|
@ApiOperation("Gets a sheet")
|
||||||
public BasePostDetailDTO getBy(@PathVariable("sheetId") Integer sheetId,
|
public SheetDetailVO getBy(@PathVariable("sheetId") Integer sheetId,
|
||||||
@RequestParam(value = "formatDisabled", required = false, defaultValue = "true") Boolean formatDisabled,
|
@RequestParam(value = "formatDisabled", required = false, defaultValue = "true") Boolean formatDisabled,
|
||||||
@RequestParam(value = "sourceDisabled", required = false, defaultValue = "false") Boolean sourceDisabled) {
|
@RequestParam(value = "sourceDisabled", required = false, defaultValue = "false") Boolean sourceDisabled) {
|
||||||
BasePostDetailDTO sheetDetailVO = sheetService.convertToDetail(sheetService.getById(sheetId));
|
SheetDetailVO sheetDetailVO = sheetService.convertToDetailVo(sheetService.getById(sheetId));
|
||||||
|
|
||||||
if (formatDisabled) {
|
if (formatDisabled) {
|
||||||
// Clear the format content
|
// Clear the format content
|
||||||
|
|
Loading…
Reference in New Issue