PageController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Modules\Mini\Controllers;
  3. use App\Base\BaseController;
  4. use App\Modules\Mini\Services\PageService;
  5. use Faker\Provider\Image;
  6. class PageController extends BaseController
  7. {
  8. protected PageService $service;
  9. /**
  10. * @param PageService $service
  11. */
  12. public function __construct(PageService $service)
  13. {
  14. $this->service = $service;
  15. }
  16. public function filterConfig()
  17. {
  18. $params = $this->valid([
  19. "type" => "",
  20. ]);
  21. return $this->ok([
  22. "list" => $this->service->filterConfig($params),
  23. ]);
  24. }
  25. public function home()
  26. {
  27. return $this->ok([
  28. "banner" => $this->service->banner(),
  29. "categoryTree" => $this->service->categoryTree("home"),
  30. "hot_goods" => $this->service->hotGoods(10),
  31. "recommend_goods" => $this->service->recommendedGoods(10),
  32. ]);
  33. }
  34. public function categoryGoods()
  35. {
  36. $params = $this->valid([
  37. "id" => "required",
  38. "page_size" => "int",
  39. "keyword" => "",
  40. "attrs" => "",
  41. ]);
  42. return $this->ok($this->service->categoryGoods($params));
  43. }
  44. public function categoryTree()
  45. {
  46. return $this->ok([
  47. "categoryTree" => $this->service->categoryTree("category"),
  48. ]);
  49. }
  50. public function search()
  51. {
  52. $params = $this->valid([
  53. "keyword" => "",
  54. "attrs" => "",
  55. ]);
  56. return $this->ok($this->service->search($params));
  57. }
  58. }