About.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\db\exception\DataNotFoundException;
  5. use think\db\exception\ModelNotFoundException;
  6. use think\Exception;
  7. use think\exception\DbException;
  8. /**
  9. * 文章接口
  10. */
  11. class About extends Api
  12. {
  13. //如果$noNeedLogin为空表示所有接口都需要登录才能请求
  14. //如果$noNeedRight为空表示所有接口都需要验证权限才能请求
  15. //如果接口已经设置无需登录,那也就无需鉴权了
  16. //
  17. // 无需登录的接口,*表示全部
  18. protected $noNeedLogin = ['*'];
  19. // 无需鉴权的接口,*表示全部
  20. protected $noNeedRight = ['*'];
  21. /**
  22. * @throws Exception
  23. * @throws DataNotFoundException
  24. * @throws ModelNotFoundException
  25. * @throws DbException
  26. */
  27. public function list()
  28. {
  29. $where = $this->request->param();
  30. $where['lang'] = $this->lang;
  31. $this->success('ok', \app\admin\model\about\About::getValidArticleList($where));
  32. }
  33. /**
  34. * @param $id
  35. * @throws DataNotFoundException
  36. * @throws DbException
  37. * @throws ModelNotFoundException
  38. */
  39. public function detail($id)
  40. {
  41. $this->success('ok', \app\admin\model\about\About::getValidArticle($id, $this->lang, true));
  42. }
  43. }