SpecialGoodsController.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\admin\controller\goods;
  3. use app\admin\service\goods\GoodsService;
  4. use app\admin\validate\goods\GoodsValidate;
  5. use support\Request;
  6. use support\Response;
  7. class SpecialGoodsController
  8. {
  9. /**
  10. * @Desc 列表
  11. * @Author Gorden
  12. * @Date 2024/3/28 10:08
  13. *
  14. * @param Request $request
  15. * @return Response
  16. */
  17. public function select(Request $request)
  18. {
  19. return GoodsService::selectSpecial($request);
  20. }
  21. /**
  22. * @Desc 商品详情
  23. * @Author Gorden
  24. * @Date 2024/3/28 10:25
  25. *
  26. * @param Request $request
  27. * @return Response
  28. */
  29. public function info(Request $request)
  30. {
  31. $validate = new GoodsValidate();
  32. if (!$validate->scene('info')->check($request->get())) {
  33. return json_fail($validate->getError());
  34. }
  35. return GoodsService::info($request->get('goods_id'));
  36. }
  37. /**
  38. * @Desc 添加商品
  39. * @Author Gorden
  40. * @Date 2024/3/11 10:21
  41. *
  42. * @param Request $request
  43. * @return Response
  44. */
  45. public function insert(Request $request): Response
  46. {
  47. $params = $request->post();
  48. $validate = new GoodsValidate();
  49. if (!$validate->scene('add')->check($params)) {
  50. return json_fail($validate->getError());
  51. }
  52. return GoodsService::insert($params);
  53. }
  54. /**
  55. * @Desc 修改商品
  56. * @Author Gorden
  57. * @Date 2024/3/28 13:22
  58. *
  59. * @param Request $request
  60. * @return Response
  61. */
  62. public function update(Request $request): Response
  63. {
  64. $validate = new GoodsValidate();
  65. if (!$validate->scene('update')->check($request->post())) {
  66. return json_fail($validate->getError());
  67. }
  68. return GoodsService::update($request->post());
  69. }
  70. /**
  71. * @Desc 删除商品
  72. * @Author Gorden
  73. * @Date 2024/3/28 13:22
  74. *
  75. * @param Request $request
  76. * @return Response
  77. */
  78. public function delete(Request $request)
  79. {
  80. $ids = $request->post('goods_id');
  81. return GoodsService::delete($ids);
  82. }
  83. }