Add TagController for portal api

pull/137/head
johnniang 2019-04-02 23:10:05 +08:00
parent 54a1b59a15
commit 87264d89bc
2 changed files with 45 additions and 1 deletions

View File

@ -35,7 +35,7 @@ public class CategoryController {
this.postCategoryService = postCategoryService; this.postCategoryService = postCategoryService;
} }
@GetMapping("tree") @GetMapping("tree_view")
@ApiOperation("List as category tree") @ApiOperation("List as category tree")
public List<CategoryVO> listAsTree(@SortDefault(sort = "name", direction = ASC) Sort sort) { public List<CategoryVO> listAsTree(@SortDefault(sort = "name", direction = ASC) Sort sort) {
return categoryService.listAsTree(sort); return categoryService.listAsTree(sort);

View File

@ -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<? 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 tagService.convertTo(tagService.listAll(sort));
}
}