12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\ModelNotFoundException;
- use think\Exception;
- use think\exception\DbException;
- /**
- * 文章接口
- */
- class About extends Api
- {
- //如果$noNeedLogin为空表示所有接口都需要登录才能请求
- //如果$noNeedRight为空表示所有接口都需要验证权限才能请求
- //如果接口已经设置无需登录,那也就无需鉴权了
- //
- // 无需登录的接口,*表示全部
- protected $noNeedLogin = ['*'];
- // 无需鉴权的接口,*表示全部
- protected $noNeedRight = ['*'];
- /**
- * @throws Exception
- * @throws DataNotFoundException
- * @throws ModelNotFoundException
- * @throws DbException
- */
- public function list()
- {
- $where = $this->request->param();
- $where['lang'] = $this->lang;
- $this->success('ok', \app\admin\model\about\About::getValidArticleList($where));
- }
- /**
- * @param $id
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- */
- public function detail($id)
- {
- $this->success('ok', \app\admin\model\about\About::getValidArticle($id, $this->lang, true));
- }
- }
|