123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\api\model\ArticleModel;
- /**
- * 资讯接口
- * @ApiWeigh (97)
- */
- class Article extends Api
- {
- protected $noNeedLogin = [];//,'my_keys','my_detail'
- protected $noNeedRight = ['*'];
- /**
- * 全部资讯
- *
- * @ApiTitle (全部资讯)
- * @ApiSummary (全部资讯)
- * @ApiMethod (POST)
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
- * @ApiRoute (/api/article/article_list)
- * @ApiParams (name="user_id", type="int", required=true, description="用户id")
- * @ApiParams (name="token", type="int", required=true, description="请求的Token")
- * @ApiReturn ()
- */
- public function article_list(){
- $userId = $this->request->post('user_id');
- if (empty($userId)){
- $this->result('登录信息丢失');
- }
- $get_list=ArticleModel::where(['status'=>'1','is_delete'=>'0'])->order('id desc')->field('id,title,images,createtime')->select();
- $this->result('success', $get_list, 1);
- }
- /**
- * 资讯详情
- *
- * @ApiTitle (资讯详情)
- * @ApiSummary (资讯详情)
- * @ApiMethod (POST)
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
- * @ApiRoute (/api/article/article_detail)
- * @ApiParams (name="user_id", type="int", required=true, description="用户id")
- * @ApiParams (name="token", type="int", required=true, description="请求的Token")
- * @ApiParams (name="article_id", type="int", required=true, description="列表中的id")
- * @ApiReturn ()
- */
- public function article_detail(){
- $userId = $this->request->post('user_id');
- if (empty($userId)){
- $this->result('登录信息丢失');
- }
- $article_id = $this->request->post('article_id');
- $get_list=ArticleModel::where(['status'=>'1','is_delete'=>'0','id'=>$article_id])->field('id,title,images,createtime,content')->find();
- $this->result('success', $get_list, 1);
- }
- }
|