12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- use app\common\library\Keyworld;
- /**
- * 视频
- */
- class Video extends Api
- {
- protected $noNeedLogin = ['typelist','lists','info','good'];
- protected $noNeedRight = ['*'];
- public function typelist(){
- $list = Db::name('video_type')->where('is_show',1)->order('weigh desc')->select();
- $this->success('success',$list);
- }
- public function lists(){
- $type_id = input('type_id',0);
- $where = [
- 'is_show' => 1
- ];
- if($type_id){
- $where['type_id'] = $type_id;
- }
- $list = Db::name('video')->where($where)->order('weigh desc')->autopage()->select();
- $list = list_domain_image($list,['video_file','video_image']);
- $this->success('success',$list);
- }
- //获取详情
- public function info(){
- $id = input('id',0);
- $info = Db::name('video')->where('id',$id)->find();
- $info = info_domain_image($info,['video_file','video_image']);
- $this->success('success',$info);
- }
- //点赞
- public function good(){
- $id = input('id');
- Db::name('video')->where('id',$id)->setInc('goodnum');
- $this->success('点赞成功');
- }
- //评论
- public function answer(){
- $id = input('id',0);
- $info = input('info','');
- if(empty($info) || empty($id)){
- $this->error();
- }
- //关键字替换
- $info = Keyworld::sensitive($info);
- //data
- $data = [
- 'video_id' => $id,
- 'user_id' => $this->auth->id,
- 'info' => $info,
- 'createtime' => time(),
- 'updatetime' => time(),
- ];
- Db::startTrans();
- $rs = Db::name('video_answer')->insertGetId($data);
- $answernum = Db::name('video')->where('id',$id)->setInc('answernum');
- Db::commit();
- $this->success('评价成功');
- }
- }
|