Refactor listTags api

pull/137/head
johnniang 2019-03-25 22:05:49 +08:00
parent 836e9975e8
commit a8eb88956c
4 changed files with 17 additions and 18 deletions

View File

@ -70,7 +70,7 @@ public class CommentController {
} }
@PutMapping("{commentId:\\d+}/status/{status}") @PutMapping("{commentId:\\d+}/status/{status}")
@ApiOperation("Update comment status") @ApiOperation("Updates comment status")
public CommentOutputDTO updateStatusBy(@PathVariable("commentId") Long commentId, public CommentOutputDTO updateStatusBy(@PathVariable("commentId") Long commentId,
@PathVariable("status") CommentStatus status) { @PathVariable("status") CommentStatus status) {
// Update comment status // Update comment status
@ -80,6 +80,7 @@ public class CommentController {
} }
@DeleteMapping("{commentId:\\d+}") @DeleteMapping("{commentId:\\d+}")
@ApiOperation("Deletes comment permanently and recursively")
public CommentOutputDTO deleteBy(@PathVariable("commentId") Long commentId) { public CommentOutputDTO deleteBy(@PathVariable("commentId") Long commentId) {
// Get comment by id // Get comment by id
Comment comment = commentService.getById(commentId); Comment comment = commentService.getById(commentId);

View File

@ -39,23 +39,23 @@ public class GalleryController {
/** /**
* Get gallery by id. * Get gallery by id.
* *
* @param id gallery id * @param galleryId gallery id
* @return GalleryOutputDTO * @return GalleryOutputDTO
*/ */
@GetMapping("{id:\\d+}") @GetMapping("{galleryId:\\d+}")
@ApiOperation("Get gallery detail by id") @ApiOperation("Get gallery detail by id")
public GalleryOutputDTO getBy(@PathVariable("id") Integer id) { public GalleryOutputDTO getBy(@PathVariable("galleryId") Integer galleryId) {
return new GalleryOutputDTO().convertFrom(galleryService.getById(id)); return new GalleryOutputDTO().convertFrom(galleryService.getById(galleryId));
} }
/** /**
* Delete gallery by id. * Delete gallery by id.
* *
* @param id id * @param galleryId gallery id
*/ */
@DeleteMapping("{id:\\d+}") @DeleteMapping("{galleryId:\\d+}")
@ApiOperation("Delete gallery by id") @ApiOperation("Delete gallery by id")
public void deletePermanently(@PathVariable("id") Integer id) { public void deletePermanently(@PathVariable("galleryId") Integer galleryId) {
galleryService.removeById(id); galleryService.removeById(galleryId);
} }
} }

View File

@ -63,9 +63,9 @@ public class PostController {
@GetMapping("status/{status}") @GetMapping("status/{status}")
@ApiOperation("Gets a page of post by post status") @ApiOperation("Gets a page of post by post status")
public Page<? extends PostSimpleOutputDTO> pageByStatus(@PathVariable(name = "status") PostStatus status, public Page<? extends PostSimpleOutputDTO> pageByStatus(@PathVariable(name = "status") PostStatus status,
@RequestParam(value = "more_info", required = false, defaultValue = "false") Boolean moreInfo, @RequestParam(value = "more", required = false, defaultValue = "false") Boolean more,
@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) { @PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) {
if (moreInfo) { if (more) {
return postService.pageListVoBy(status, pageable); return postService.pageListVoBy(status, pageable);
} }
return postService.pageSimpleDtoByStatus(status, pageable); return postService.pageSimpleDtoByStatus(status, pageable);

View File

@ -1,7 +1,6 @@
package cc.ryanc.halo.web.controller.admin.api; package cc.ryanc.halo.web.controller.admin.api;
import cc.ryanc.halo.model.dto.TagOutputDTO; import cc.ryanc.halo.model.dto.TagOutputDTO;
import cc.ryanc.halo.model.dto.TagWithCountOutputDTO;
import cc.ryanc.halo.model.entity.Tag; import cc.ryanc.halo.model.entity.Tag;
import cc.ryanc.halo.model.params.TagParam; import cc.ryanc.halo.model.params.TagParam;
import cc.ryanc.halo.service.PostTagService; import cc.ryanc.halo.service.PostTagService;
@ -36,13 +35,12 @@ public class TagController {
this.postTagService = postTagService; this.postTagService = postTagService;
} }
@GetMapping("/addition") @GetMapping
public List<TagWithCountOutputDTO> listTagsWithCount(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) { public List<? extends TagOutputDTO> listTags(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort,
@RequestParam(name = "more", required = false, defaultValue = "false") Boolean more) {
if (more) {
return postTagService.listTagWithCountDtos(sort); return postTagService.listTagWithCountDtos(sort);
} }
@GetMapping
public List<TagOutputDTO> listTags(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) {
return tagService.convertTo(tagService.listAll(sort)); return tagService.convertTo(tagService.listAll(sort));
} }