EntityGoodsController.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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\GoodsDetail;
  6. use support\Request;
  7. use support\Response;
  8. class EntityGoodsController
  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, 'GOODS');
  21. }
  22. /**
  23. * @Desc 搜索产品
  24. * @Author Gorden
  25. * @Date 2024/11/8 10:12
  26. *
  27. * @param Request $request
  28. * @return Response
  29. */
  30. public function selectIdNameList(Request $request)
  31. {
  32. return GoodsService::selectIdNameList($request);
  33. }
  34. public function selectAll(Request $request)
  35. {
  36. $goodsIds = $request->get('goods_id', '');
  37. return GoodsService::selectAll($goodsIds);
  38. }
  39. public function selectAllByGoodsName(Request $request)
  40. {
  41. $goodsName = $request->get('goods_name', '');
  42. if (!$goodsName) {
  43. return json_fail("请输入要搜索的产品");
  44. }
  45. return GoodsService::selectAllByGoodsName($goodsName);
  46. }
  47. public function selectAllByCategoryForRuleAddComponent(Request $request)
  48. {
  49. $category = $request->get('category', 'GOODS');
  50. return GoodsService::selectAllByCategoryForRuleAddComponent($category);
  51. }
  52. public function selectPremisesByGoodsId(Request $request)
  53. {
  54. return GoodsService::selectPremisesByGoodsId($request->get('goods_id'));
  55. }
  56. /**
  57. * @Desc 商品详情
  58. * @Author Gorden
  59. * @Date 2024/3/28 10:25
  60. *
  61. * @param Request $request
  62. * @return Response
  63. */
  64. public function info(Request $request)
  65. {
  66. $validate = new GoodsValidate();
  67. if (!$validate->scene('info')->check($request->get())) {
  68. return json_fail($validate->getError());
  69. }
  70. return GoodsService::info($request->get('goods_id'));
  71. }
  72. /**
  73. * @Desc 添加商品
  74. * @Author Gorden
  75. * @Date 2024/3/11 10:21
  76. *
  77. * @param Request $request
  78. * @return Response
  79. */
  80. public function insert(Request $request): Response
  81. {
  82. $params = $request->post();
  83. $validate = new GoodsValidate();
  84. if (!$validate->scene('add')->check($params)) {
  85. return json_fail($validate->getError());
  86. }
  87. $params['goods_classify'] = $params['goods_classify'] ?? 'GOODS';
  88. return GoodsService::insert($params);
  89. }
  90. /**
  91. * @Desc 修改商品
  92. * @Author Gorden
  93. * @Date 2024/3/28 13:22
  94. *
  95. * @param Request $request
  96. * @return Response
  97. */
  98. public function update(Request $request): Response
  99. {
  100. $validate = new GoodsValidate();
  101. if (!$validate->scene('update')->check($request->post())) {
  102. return json_fail($validate->getError());
  103. }
  104. return GoodsService::update($request->post());
  105. }
  106. /**
  107. * @Desc 删除商品
  108. * @Author Gorden
  109. * @Date 2024/3/28 13:22
  110. *
  111. * @param Request $request
  112. * @return Response
  113. */
  114. public function delete(Request $request)
  115. {
  116. $ids = $request->post('goods_id');
  117. return GoodsService::delete($ids);
  118. }
  119. }