ServiceGoodsController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 ServiceGoodsController
  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::select($request, 'SERVICE');
  20. }
  21. public function selectList(Request $request)
  22. {
  23. return GoodsService::selectList($request, 'SERVICE');
  24. }
  25. public function selectPicking(Request $request)
  26. {
  27. return GoodsService::selectPicking($request);
  28. }
  29. /**
  30. * @Desc 商品详情
  31. * @Author Gorden
  32. * @Date 2024/3/28 10:25
  33. *
  34. * @param Request $request
  35. * @return Response
  36. */
  37. public function info(Request $request)
  38. {
  39. $validate = new GoodsValidate();
  40. if (!$validate->scene('info')->check($request->get())) {
  41. return json_fail($validate->getError());
  42. }
  43. return GoodsService::info($request->get('goods_id'));
  44. }
  45. /**
  46. * @Desc 添加商品
  47. * @Author Gorden
  48. * @Date 2024/3/11 10:21
  49. *
  50. * @param Request $request
  51. * @return Response
  52. */
  53. public function insert(Request $request): Response
  54. {
  55. $params = $request->post();
  56. $validate = new GoodsValidate();
  57. if (!$validate->scene('add')->check($params)) {
  58. return json_fail($validate->getError());
  59. }
  60. return GoodsService::insert($params);
  61. }
  62. /**
  63. * @Desc 修改商品
  64. * @Author Gorden
  65. * @Date 2024/3/28 13:22
  66. *
  67. * @param Request $request
  68. * @return Response
  69. */
  70. public function update(Request $request): Response
  71. {
  72. $validate = new GoodsValidate();
  73. if (!$validate->scene('update')->check($request->post())) {
  74. return json_fail($validate->getError());
  75. }
  76. return GoodsService::update($request->post());
  77. }
  78. public function changeStatus(Request $request): Response
  79. {
  80. $validate = new GoodsValidate();
  81. if (!$validate->scene('changeStatus')->check($request->post())) {
  82. return json_fail($validate->getError());
  83. }
  84. return GoodsService::changeStatus($request->post());
  85. }
  86. /**
  87. * @Desc 删除商品
  88. * @Author Gorden
  89. * @Date 2024/3/28 13:22
  90. *
  91. * @param Request $request
  92. * @return Response
  93. */
  94. public function delete(Request $request)
  95. {
  96. $ids = $request->post('goods_id');
  97. return GoodsService::delete($ids);
  98. }
  99. }