作者 郭盛
1 个管道 的构建 通过 耗费 1 秒

修改浏览量

... ... @@ -51,4 +51,40 @@ class Information extends Api
$this->success('success',$data);
}
/**
* @ApiTitle (资讯新闻增加浏览量)
* @ApiSummary (资讯新闻增加浏览量)
* @ApiMethod (POST)
* @ApiRoute (/api/information/add_num)
*
* @ApiParams (name="id", type="int", required=false, description="农业资讯ID")
*
* @ApiReturn({
"code": 1,
"msg": "SUCCESS",
"time": "1553839125",
"data": {
}
})
*/
public function add_num()
{
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
}
$data = Db::name('information')
->where('id',$id)
->find();
$look_num = $data['look_num'] + 1;
$res = Db::name('information')->where('id',$id)->update(['look_num'=>$look_num]);
if(!empty($res)){
$this->success('成功');
}else{
$this->error('失败');
}
}
}
\ No newline at end of file
... ...