TravelGoodsController.php 2.5 KB

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