ServiceGoodsController.php 2.8 KB

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