PackageGoodsController.php 2.4 KB

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