diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/api/CategoryController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/api/CategoryController.java index 4f6fc1f31..38f96669f 100644 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/api/CategoryController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/api/CategoryController.java @@ -35,7 +35,7 @@ public class CategoryController { this.postCategoryService = postCategoryService; } - @GetMapping("tree") + @GetMapping("tree_view") @ApiOperation("List as category tree") public List listAsTree(@SortDefault(sort = "name", direction = ASC) Sort sort) { return categoryService.listAsTree(sort); diff --git a/src/main/java/cc/ryanc/halo/web/controller/portal/api/TagController.java b/src/main/java/cc/ryanc/halo/web/controller/portal/api/TagController.java new file mode 100644 index 000000000..289f40c97 --- /dev/null +++ b/src/main/java/cc/ryanc/halo/web/controller/portal/api/TagController.java @@ -0,0 +1,44 @@ +package cc.ryanc.halo.web.controller.portal.api; + +import cc.ryanc.halo.model.dto.TagOutputDTO; +import cc.ryanc.halo.service.PostTagService; +import cc.ryanc.halo.service.TagService; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Sort; +import org.springframework.data.web.SortDefault; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * Portal tag controller. + * + * @author johnniang + * @date 4/2/19 + */ +@RestController +@RequestMapping("/api/tags") +public class TagController { + + private final TagService tagService; + + private final PostTagService postTagService; + + public TagController(TagService tagService, PostTagService postTagService) { + this.tagService = tagService; + this.postTagService = postTagService; + } + + @GetMapping + @ApiOperation("Lists tags") + public List 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 tagService.convertTo(tagService.listAll(sort)); + } +}