CategoryController.java 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package com.nosum.deliver.category.controller;
  2. import com.nosum.common.validator.group.Insert;
  3. import com.nosum.common.validator.group.Update;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.validation.BindingResult;
  6. import org.springframework.validation.annotation.Validated;
  7. import org.springframework.web.bind.annotation.DeleteMapping;
  8. import org.springframework.web.bind.annotation.GetMapping;
  9. import org.springframework.web.bind.annotation.PathVariable;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.PutMapping;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import com.nosum.common.annotation.LoginRequired;
  16. import com.nosum.common.base.domain.Result;
  17. import com.nosum.common.util.ThrowableUtils;
  18. import com.nosum.deliver.category.domain.vo.CategoryVO;
  19. import com.nosum.deliver.category.service.CategoryService;
  20. /**
  21. * @author sumbytes
  22. * @since 2019-08-28
  23. */
  24. @RestController
  25. @RequestMapping("/category")
  26. public class CategoryController {
  27. @Autowired
  28. private CategoryService categoryService;
  29. @LoginRequired
  30. @PostMapping("/category/v1/add")
  31. public Result saveCategory(@Validated({Insert.class}) @RequestBody CategoryVO categoryVO, BindingResult result) {
  32. ThrowableUtils.checkParamArgument(result);
  33. return categoryService.saveCategory(categoryVO);
  34. }
  35. @LoginRequired
  36. @GetMapping("/statistics/v1/list")
  37. public Result statisticsList(CategoryVO categoryVO){
  38. return categoryService.statisticsList(categoryVO);
  39. }
  40. @LoginRequired
  41. @PutMapping("/category/v1/update")
  42. public Result updateCategory(@Validated({Update.class}) @RequestBody CategoryVO categoryVO, BindingResult result) {
  43. ThrowableUtils.checkParamArgument(result);
  44. return categoryService.updateCategory(categoryVO);
  45. }
  46. @LoginRequired
  47. @GetMapping("/category-tags/v1/{id}")
  48. public Result getCategoryTags(@PathVariable(value = "id", required = true) Long id) {
  49. return categoryService.getCategoryTags(id);
  50. }
  51. @LoginRequired
  52. @GetMapping("/category-tags/v1/list")
  53. public Result getCategoryTagsList(CategoryVO categoryVO) {
  54. return categoryService.getCategoryTagsList(categoryVO);
  55. }
  56. @GetMapping("/category/v1/{id}")
  57. public Result getCategory(@PathVariable(value = "id", required = true) Long id) {
  58. return categoryService.getCategory(id);
  59. }
  60. @GetMapping("/category/v1/list")
  61. public Result getCategoryList(CategoryVO categoryVO) {
  62. return categoryService.getCategoryList(categoryVO);
  63. }
  64. @LoginRequired
  65. @DeleteMapping("/category/v1/{id}")
  66. public Result deleteCategory(@PathVariable(value = "id", required = true) Long id) {
  67. return categoryService.deleteCategory(id);
  68. }
  69. }