mirror of https://github.com/halo-dev/halo
Merge remote-tracking branch 'origin/v1' into v1
commit
1c7e6eaeb7
|
@ -38,20 +38,20 @@ public class JournalController {
|
||||||
this.optionService = optionService;
|
this.optionService = optionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{sheetId:\\d+}/comments/tree_view")
|
@GetMapping("{journalId:\\d+}/comments/tree_view")
|
||||||
@ApiOperation("Lists comments with tree view")
|
@ApiOperation("Lists comments with tree view")
|
||||||
public Page<BaseCommentVO> listCommentsTree(@PathVariable("sheetId") Integer sheetId,
|
public Page<BaseCommentVO> listCommentsTree(@PathVariable("journalId") Integer journalId,
|
||||||
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
|
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
|
||||||
@SortDefault(sort = "createTime", direction = DESC) Sort sort) {
|
@SortDefault(sort = "createTime", direction = DESC) Sort sort) {
|
||||||
return journalCommentService.pageVosBy(sheetId, PageRequest.of(page, optionService.getCommentPageSize(), sort));
|
return journalCommentService.pageVosBy(journalId, PageRequest.of(page, optionService.getCommentPageSize(), sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{sheetId:\\d+}/comments/list_view")
|
@GetMapping("{journalId:\\d+}/comments/list_view")
|
||||||
@ApiOperation("Lists comment with list view")
|
@ApiOperation("Lists comment with list view")
|
||||||
public Page<BaseCommentWithParentVO> listComments(@PathVariable("sheetId") Integer sheetId,
|
public Page<BaseCommentWithParentVO> listComments(@PathVariable("journalId") Integer journalId,
|
||||||
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
|
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
|
||||||
@SortDefault(sort = "createTime", direction = DESC) Sort sort) {
|
@SortDefault(sort = "createTime", direction = DESC) Sort sort) {
|
||||||
return journalCommentService.pageWithParentVoBy(sheetId, PageRequest.of(page, optionService.getCommentPageSize(), sort));
|
return journalCommentService.pageWithParentVoBy(journalId, PageRequest.of(page, optionService.getCommentPageSize(), sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("comments")
|
@PostMapping("comments")
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package run.halo.app.controller.content.api;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.web.SortDefault;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import run.halo.app.model.dto.BaseCommentDTO;
|
||||||
|
import run.halo.app.model.params.SheetCommentParam;
|
||||||
|
import run.halo.app.model.vo.BaseCommentVO;
|
||||||
|
import run.halo.app.model.vo.BaseCommentWithParentVO;
|
||||||
|
import run.halo.app.service.OptionService;
|
||||||
|
import run.halo.app.service.SheetCommentService;
|
||||||
|
import run.halo.app.service.SheetService;
|
||||||
|
|
||||||
|
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sheet controller.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 19-4-26
|
||||||
|
*/
|
||||||
|
@RestController("PortalSheetController")
|
||||||
|
@RequestMapping("/api/sheets")
|
||||||
|
public class SheetController {
|
||||||
|
|
||||||
|
private final SheetService sheetService;
|
||||||
|
|
||||||
|
private final SheetCommentService sheetCommentService;
|
||||||
|
|
||||||
|
private final OptionService optionService;
|
||||||
|
|
||||||
|
public SheetController(SheetService sheetService, SheetCommentService sheetCommentService, OptionService optionService) {
|
||||||
|
this.sheetService = sheetService;
|
||||||
|
this.sheetCommentService = sheetCommentService;
|
||||||
|
this.optionService = optionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("{sheetId:\\d+}/comments/tree_view")
|
||||||
|
@ApiOperation("Lists comments with tree view")
|
||||||
|
public Page<BaseCommentVO> listCommentsTree(@PathVariable("sheetId") Integer sheetId,
|
||||||
|
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
|
||||||
|
@SortDefault(sort = "createTime", direction = DESC) Sort sort) {
|
||||||
|
return sheetCommentService.pageVosBy(sheetId, PageRequest.of(page, optionService.getCommentPageSize(), sort));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{sheetId:\\d+}/comments/list_view")
|
||||||
|
@ApiOperation("Lists comment with list view")
|
||||||
|
public Page<BaseCommentWithParentVO> listComments(@PathVariable("sheetId") Integer sheetId,
|
||||||
|
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
|
||||||
|
@SortDefault(sort = "createTime", direction = DESC) Sort sort) {
|
||||||
|
return sheetCommentService.pageWithParentVoBy(sheetId, PageRequest.of(page, optionService.getCommentPageSize(), sort));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("comments")
|
||||||
|
@ApiOperation("Comments a post")
|
||||||
|
public BaseCommentDTO comment(@RequestBody SheetCommentParam sheetCommentParam) {
|
||||||
|
return sheetCommentService.convertTo(sheetCommentService.createBy(sheetCommentParam));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue