Home.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\controller\api;
  3. use app\extra\basic\Base;
  4. use app\middleware\HomeMiddleware;
  5. use app\model\cpa\CpaPage;
  6. use LinFly\Annotation\Attributes\Route\Controller;
  7. use LinFly\Annotation\Attributes\Route\GetMapping;
  8. use LinFly\Annotation\Attributes\Route\Middleware;
  9. use support\Request;
  10. use support\Response;
  11. #[Controller("/web"),Middleware(HomeMiddleware::class)]
  12. class Home extends Base
  13. {
  14. #[GetMapping('portal')]
  15. public function getDesignData(Request $request): Response
  16. {
  17. try {
  18. $param = $request->all();
  19. if (empty($param['pageId'])) return error("参数错误");
  20. $page = (new CpaPage)->where("link_code",$param['pageId'])->findOrEmpty();
  21. if ($page->isEmpty()) return error("数据错误");
  22. return success("success",[
  23. "title" => $page['title'],
  24. "design" => $page['content']
  25. ]);
  26. } catch (\Throwable $th) {
  27. return error($th->getMessage());
  28. }
  29. }
  30. }