CardController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\admin\controller\goods;
  3. use app\admin\service\goods\CardService;
  4. use app\admin\service\goods\GoodsService;
  5. use app\admin\service\goods\PartnerService;
  6. use app\admin\validate\goods\GoodsValidate;
  7. use support\Request;
  8. use support\Response;
  9. class CardController
  10. {
  11. /**
  12. * @Desc 商品详情
  13. * @Author Gorden
  14. * @Date 2024/3/28 10:25
  15. *
  16. * @param Request $request
  17. * @return Response
  18. */
  19. public function info(Request $request)
  20. {
  21. $validate = new GoodsValidate();
  22. if (!$validate->scene('info')->check($request->get())) {
  23. return json_fail($validate->getError());
  24. }
  25. return CardService::info($request->get('goods_id'));
  26. }
  27. /**
  28. * @Desc 添加商品
  29. * @Author Gorden
  30. * @Date 2024/3/11 10:21
  31. *
  32. * @param Request $request
  33. * @return Response
  34. */
  35. public function insert(Request $request): Response
  36. {
  37. $params = $request->post();
  38. $validate = new GoodsValidate();
  39. if (!$validate->scene('add')->check($params)) {
  40. return json_fail($validate->getError());
  41. }
  42. $params['goods_classify'] = $params['goods_classify'] ?? 'GOODS';
  43. return CardService::insert($params);
  44. }
  45. /**
  46. * @Desc 修改商品
  47. * @Author Gorden
  48. * @Date 2024/3/28 13:22
  49. *
  50. * @param Request $request
  51. * @return Response
  52. */
  53. public function update(Request $request): Response
  54. {
  55. $validate = new GoodsValidate();
  56. if (!$validate->scene('update')->check($request->post())) {
  57. return json_fail($validate->getError());
  58. }
  59. return CardService::update($request->post());
  60. }
  61. }