Goods.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\api\controller;
  13. use app\api\model\Goods as GoodsModel;
  14. /**
  15. * 商品控制器
  16. * Class Goods
  17. * @package app\api\controller
  18. */
  19. class Goods extends Controller
  20. {
  21. /**
  22. * 商品列表
  23. * @return array
  24. * @throws \think\db\exception\DbException
  25. */
  26. public function list()
  27. {
  28. // 获取列表数据
  29. $model = new GoodsModel;
  30. $list = $model->getList($this->request->param());
  31. return $this->renderSuccess(compact('list'));
  32. }
  33. /**
  34. * 获取商品详情
  35. * @param int $goodsId
  36. * @return array|\think\response\Json
  37. * @throws \app\common\exception\BaseException
  38. * @throws \think\db\exception\DataNotFoundException
  39. * @throws \think\db\exception\DbException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. */
  42. public function detail(int $goodsId)
  43. {
  44. // 商品详情
  45. $model = new GoodsModel;
  46. $goodsInfo = $model->getDetails($goodsId);
  47. return $this->renderSuccess(['detail' => $goodsInfo]);
  48. }
  49. }