Product.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\ProductServer;
  5. class Product extends BaseController
  6. {
  7. /**
  8. * Notes:获取智能产品列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/9/19
  12. */
  13. public function getProductList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = ProductServer::getProductList($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 getProductAll()
  27. {
  28. $result = ProductServer::getProductAll();
  29. return json_success($result, '成功');
  30. }
  31. /**
  32. * Notes:修改智能产品
  33. * @return \support\Response
  34. * User: ZQ
  35. * Date: 2022/9/13
  36. */
  37. public function updateProduct()
  38. {
  39. $product_id = $this->request->post('product_id');
  40. $product_category_id = $this->request->post('product_category_id');
  41. $product_name = $this->request->post('product_name');
  42. $product_content = $this->request->post('product_content');
  43. $this->validateCheck('intelligence\ProductValidate', ['product_id' => $product_id], 'update');
  44. $result = ProductServer::updateProduct($product_id, $product_category_id, $product_name, $product_content);
  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 delProduct()
  54. {
  55. $product_id = $this->request->get('product_id');
  56. $this->validateCheck('intelligence\ProductValidate', ['product_id' => $product_id], 'info');
  57. $result = ProductServer::delProduct($product_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 addProduct()
  71. {
  72. $product_category_id = $this->request->post('product_category_id');
  73. $product_name = $this->request->post('product_name');
  74. $product_content = $this->request->post('product_content');
  75. $this->validateCheck('intelligence\ProductValidate', ['product_category_id' => $product_category_id, 'product_name' => $product_name], 'create');
  76. $result = ProductServer::insertProduct($product_name, $product_category_id, $product_content);
  77. return json_success($result, '添加成功');
  78. }
  79. /**
  80. * Notes:查询智能产品详情
  81. * @return \support\Response
  82. * User: ZQ
  83. * Date: 2022/9/19
  84. */
  85. public function productInfo()
  86. {
  87. $product_id = $this->request->get('product_id');
  88. $this->validateCheck('intelligence\ProductValidate', ['product_id' => $product_id], 'info');
  89. $result = ProductServer::productInfo($product_id);
  90. return json_success($result, '成功');
  91. }
  92. }