GoodsController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\BaseController;
  4. use App\Http\Validator\ActivityValidator;
  5. use App\Services\ActivityBooksService;
  6. use App\Services\ActivityService;
  7. use App\Services\GoodsCatesService;
  8. use App\Services\GoodsService;
  9. use Illuminate\Http\Request;
  10. /**
  11. * 商城商品控制器类
  12. * @author wesmiler
  13. * @since 2020/11/10
  14. * Class GoodsController
  15. * @package App\Http\Controllers
  16. */
  17. class GoodsController extends BaseController
  18. {
  19. /**
  20. * 构造函数
  21. * @author wesmiler
  22. * @since 2020/11/11
  23. * GoodsController constructor.
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. $this->service = new GoodsService();
  29. $this->cateService = new GoodsCatesService();
  30. }
  31. /**
  32. * 列表
  33. * @return array
  34. */
  35. public function index(){
  36. return $this->service->getDataList();
  37. }
  38. /**
  39. * 详情
  40. * @return array|mixed
  41. */
  42. public function info(){
  43. $id = request()->get('id', 0);
  44. return $this->service->getDetail($id);
  45. }
  46. /**
  47. * 获取分类
  48. * @return mixed
  49. */
  50. public function cates(){
  51. return $this->cateService->getOptions();
  52. }
  53. }