Category.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\admin\controller\intelligence;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\intelligence\CategoryServer;
  5. class Category extends BaseController
  6. {
  7. /**
  8. * Notes:获取智能产品分类列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/9/19
  12. */
  13. public function getCategoryList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = CategoryServer::getCategoryList($page, $limit, $keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:获取所有智能产品分类
  22. * @return \support\Response
  23. * User: ZQ
  24. * Date: 2022/9/19
  25. */
  26. public function getCategoryAll()
  27. {
  28. $type = $this->request->get('type'); //1:所有;2:1级
  29. $result = CategoryServer::getCategoryAll($type);
  30. return json_success($result, '成功');
  31. }
  32. /**
  33. * Notes:修改智能产品分类
  34. * @return \support\Response
  35. * User: ZQ
  36. * Date: 2022/9/13
  37. */
  38. public function updateCategory()
  39. {
  40. $category_id = $this->request->post('category_id');
  41. $category_name = $this->request->post('category_name');
  42. $category_pid = $this->request->post('category_pid');
  43. $this->validateCheck('intelligence\CategoryValidate', ['category_id' => $category_id], 'update');
  44. $result = CategoryServer::updateCategory($category_id, $category_name, $category_pid);
  45. return json_success($result, '修改成功');
  46. }
  47. /**
  48. * Notes:删除智能产品分类
  49. * @return \support\Response
  50. * User: ZQ
  51. * Date: 2022/9/119
  52. */
  53. public function delCategory()
  54. {
  55. $category_id = $this->request->get('category_id');
  56. $this->validateCheck('intelligence\CategoryValidate', ['category_id' => $category_id], 'info');
  57. $result = CategoryServer::delCategory($category_id);
  58. if ($result){
  59. return json_success($result, '删除成功');
  60. }else{
  61. throw new \Exception('删除失败!');
  62. }
  63. }
  64. /**
  65. * Notes:添加智能产品
  66. * @return \support\Response
  67. * User: ZQ
  68. * Date: 2022/9/19
  69. */
  70. public function addCategory()
  71. {
  72. $category_id = $this->request->post('category_id');
  73. $category_name = $this->request->post('category_name');
  74. $category_pid = $this->request->post('category_pid');
  75. $this->validateCheck('intelligence\CategoryValidate', ['category_id' => $category_id, 'category_name' => $category_name, 'category_pid' => $category_pid], 'create');
  76. $result = CategoryServer::insertCategory($category_name, $category_pid);
  77. return json_success($result, '添加成功');
  78. }
  79. /**
  80. * Notes:查询智能产品分类详情
  81. * @return \support\Response
  82. * User: ZQ
  83. * Date: 2022/9/22
  84. */
  85. public function categoryInfo()
  86. {
  87. $category_id = $this->request->get('category_id');
  88. $this->validateCheck('intelligence\CategoryValidate', ['category_id' => $category_id], 'info');
  89. $result = CategoryServer::categoryInfo($category_id);
  90. return json_success($result, '成功');
  91. }
  92. }