正在显示
1 个修改的文件
包含
36 行增加
和
0 行删除
@@ -51,4 +51,40 @@ class Information extends Api | @@ -51,4 +51,40 @@ class Information extends Api | ||
51 | $this->success('success',$data); | 51 | $this->success('success',$data); |
52 | 52 | ||
53 | } | 53 | } |
54 | + | ||
55 | + /** | ||
56 | + * @ApiTitle (资讯新闻增加浏览量) | ||
57 | + * @ApiSummary (资讯新闻增加浏览量) | ||
58 | + * @ApiMethod (POST) | ||
59 | + * @ApiRoute (/api/information/add_num) | ||
60 | + * | ||
61 | + * @ApiParams (name="id", type="int", required=false, description="农业资讯ID") | ||
62 | + * | ||
63 | + * @ApiReturn({ | ||
64 | + "code": 1, | ||
65 | + "msg": "SUCCESS", | ||
66 | + "time": "1553839125", | ||
67 | + "data": { | ||
68 | + | ||
69 | + } | ||
70 | + }) | ||
71 | + */ | ||
72 | + public function add_num() | ||
73 | + { | ||
74 | + $id = $this->request->param('id'); | ||
75 | + if(empty($id)){ | ||
76 | + $this->error('缺少必要参数'); | ||
77 | + } | ||
78 | + $data = Db::name('information') | ||
79 | + ->where('id',$id) | ||
80 | + ->find(); | ||
81 | + $look_num = $data['look_num'] + 1; | ||
82 | + $res = Db::name('information')->where('id',$id)->update(['look_num'=>$look_num]); | ||
83 | + if(!empty($res)){ | ||
84 | + $this->success('成功'); | ||
85 | + }else{ | ||
86 | + $this->error('失败'); | ||
87 | + } | ||
88 | + | ||
89 | + } | ||
54 | } | 90 | } |
-
请 注册 或 登录 后发表评论