WebController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller;
  4. use App\JsonRpc\NewsServiceInterface;
  5. use App\JsonRpc\WebsiteServiceInterface;
  6. use App\Tools\PublicData;
  7. use Hyperf\Di\Annotation\Inject;
  8. use Hyperf\HttpServer\Annotation\AutoController;
  9. use App\Tools\Result;
  10. use Hyperf\Validation\Contract\ValidatorFactoryInterface;
  11. use App\Constants\ErrorCode;
  12. use Hyperf\Context\Context;
  13. /**
  14. * Class WebController
  15. * @package App\Controller
  16. */
  17. class WebController extends AbstractController
  18. {
  19. #[Inject]
  20. protected ValidatorFactoryInterface $validationFactory;
  21. /**
  22. * @var NewsServiceInterface
  23. */
  24. #[Inject]
  25. private $newsServiceClient;
  26. /**
  27. * @var WebsiteServiceInterface
  28. */
  29. #[Inject]
  30. private $websiteServiceClient;
  31. /**
  32. * 获取栏目导航
  33. * @return array
  34. */
  35. public function getWebsiteCategory()
  36. {
  37. $data = [
  38. 'website_id'=>Context::get("SiteId")
  39. ];
  40. var_dump("网站id:",Context::get("SiteId"));
  41. $result = $this->websiteServiceClient->getWebsiteCategory($data);
  42. if ($result['code'] != ErrorCode::SUCCESS) {
  43. return Result::error($result['message'],0,[]);
  44. }
  45. return Result::success($result['data']);
  46. }
  47. }