diff --git a/src/main/java/run/halo/app/controller/admin/api/SheetController.java b/src/main/java/run/halo/app/controller/admin/api/SheetController.java index 5eaeeae15..169aec7a2 100644 --- a/src/main/java/run/halo/app/controller/admin/api/SheetController.java +++ b/src/main/java/run/halo/app/controller/admin/api/SheetController.java @@ -5,11 +5,11 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; import org.springframework.web.bind.annotation.*; -import run.halo.app.model.dto.post.SheetDetailDTO; -import run.halo.app.model.vo.SheetListVO; +import run.halo.app.model.dto.post.BasePostDetailDTO; import run.halo.app.model.entity.Sheet; import run.halo.app.model.enums.PostStatus; import run.halo.app.model.params.SheetParam; +import run.halo.app.model.vo.SheetListVO; import run.halo.app.service.SheetService; import javax.validation.Valid; @@ -34,28 +34,28 @@ public class SheetController { @GetMapping("{sheetId:\\d+}") @ApiOperation("Gets a sheet") - public SheetDetailDTO getBy(@PathVariable("sheetId") Integer sheetId) { + public BasePostDetailDTO getBy(@PathVariable("sheetId") Integer sheetId) { Sheet sheet = sheetService.getById(sheetId); - return sheetService.convertToDetailDto(sheet); + return sheetService.convertToDetail(sheet); } @GetMapping @ApiOperation("Gets a page of sheet") public Page pageBy(@PageableDefault(sort = "editTime", direction = DESC) Pageable pageable) { Page sheetPage = sheetService.pageBy(pageable); - return sheetService.convertToListDto(sheetPage); + return sheetService.convertToListVo(sheetPage); } @PostMapping @ApiOperation("Creates a sheet") - public SheetDetailDTO createBy(@RequestBody @Valid SheetParam sheetParam) { + public BasePostDetailDTO createBy(@RequestBody @Valid SheetParam sheetParam) { Sheet sheet = sheetService.createBy(sheetParam.convertTo()); - return sheetService.convertToDetailDto(sheet); + return sheetService.convertToDetail(sheet); } @PutMapping("{sheetId:\\d+}") @ApiOperation("Updates a sheet") - public SheetDetailDTO updateBy( + public BasePostDetailDTO updateBy( @PathVariable("sheetId") Integer sheetId, @RequestBody @Valid SheetParam sheetParam) { Sheet sheetToUpdate = sheetService.getById(sheetId); @@ -64,7 +64,7 @@ public class SheetController { Sheet sheet = sheetService.updateBy(sheetToUpdate); - return sheetService.convertToDetailDto(sheet); + return sheetService.convertToDetail(sheet); } @PutMapping("{sheetId:\\d+}/{status}") @@ -82,8 +82,8 @@ public class SheetController { @DeleteMapping("{sheetId:\\d+}") @ApiOperation("Deletes a sheet") - public SheetDetailDTO deleteBy(@PathVariable("sheetId") Integer sheetId) { + public BasePostDetailDTO deleteBy(@PathVariable("sheetId") Integer sheetId) { Sheet sheet = sheetService.removeById(sheetId); - return sheetService.convertToDetailDto(sheet); + return sheetService.convertToDetail(sheet); } } diff --git a/src/main/java/run/halo/app/controller/content/ContentSheetController.java b/src/main/java/run/halo/app/controller/content/ContentSheetController.java index d67cf116d..0eaad2b11 100644 --- a/src/main/java/run/halo/app/controller/content/ContentSheetController.java +++ b/src/main/java/run/halo/app/controller/content/ContentSheetController.java @@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import run.halo.app.model.entity.Sheet; import run.halo.app.model.enums.PostStatus; -import run.halo.app.service.PostCommentService; import run.halo.app.service.SheetService; import run.halo.app.service.ThemeService; @@ -22,15 +21,11 @@ public class ContentSheetController { private final SheetService sheetService; - private final PostCommentService postCommentService; - private final ThemeService themeService; public ContentSheetController(SheetService sheetService, - PostCommentService postCommentService, ThemeService themeService) { this.sheetService = sheetService; - this.postCommentService = postCommentService; this.themeService = themeService; } @@ -67,7 +62,7 @@ public class ContentSheetController { Model model) { Sheet sheet = sheetService.getBy(PostStatus.PUBLISHED, url); - model.addAttribute("sheet", sheetService.convertToDetailDto(sheet)); + model.addAttribute("sheet", sheetService.convertToDetail(sheet)); if (StrUtil.isNotEmpty(sheet.getTemplate())) { return themeService.render(sheet.getTemplate()); diff --git a/src/main/java/run/halo/app/service/SheetService.java b/src/main/java/run/halo/app/service/SheetService.java index e320f3928..a3f2f74cb 100644 --- a/src/main/java/run/halo/app/service/SheetService.java +++ b/src/main/java/run/halo/app/service/SheetService.java @@ -37,16 +37,6 @@ public interface SheetService extends BasePostService { @Override Sheet getBy(PostStatus status, String url); - /** - * Converts to detail dto. - * - * @param sheet sheet must not be null - * @return sheet detail dto - */ - @NonNull - SheetDetailDTO convertToDetailDto(@NonNull Sheet sheet); - - /** * Converts to list dto page. * @@ -54,7 +44,7 @@ public interface SheetService extends BasePostService { * @return a page of sheet list dto */ @NonNull - Page convertToListDto(@NonNull Page sheetPage); + Page convertToListVo(@NonNull Page sheetPage); } diff --git a/src/main/java/run/halo/app/service/impl/SheetServiceImpl.java b/src/main/java/run/halo/app/service/impl/SheetServiceImpl.java index 07d77f660..789d6764c 100644 --- a/src/main/java/run/halo/app/service/impl/SheetServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/SheetServiceImpl.java @@ -80,15 +80,7 @@ public class SheetServiceImpl extends BasePostServiceImpl implements Shee } @Override - public SheetDetailDTO convertToDetailDto(Sheet sheet) { - Assert.notNull(sheet, "Sheet must not be null"); - - // Convert and return - return new SheetDetailDTO().convertFrom(sheet); - } - - @Override - public Page convertToListDto(Page sheetPage) { + public Page convertToListVo(Page sheetPage) { Assert.notNull(sheetPage, "Sheet page must not be null"); // Get all sheet id