value('video_id'); $collect_check = UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$video_id,'children_id'=>$url_id])->find(); if($collect_check) { UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$video_id,'children_id'=>$url_id])->delete(); $this->success('取消收藏成功',['status'=>0]); }else{ Data::save('UserCollect', [ 'user_id'=>$this->user_id, 'coll_type'=>$coll_type, 'coll_id'=>$video_id, 'children_id'=>$url_id, 'create_int'=>time()],'user_id',['user_id'=>$this->user_id,'coll_type'=>$coll_type, 'coll_id'=>$video_id,'children_id'=>$url_id]); $this->success('收藏成功',['status'=>1]); } } /** * @title 获取用户收藏列表 * @desc 获取用户收藏列表 * @author qc * @method GET * @url /api/Collect/getUserCollectList * @header name:Authorization require:1 desc:Token * @param name:page type:int default:1 desc:页数 * @param name:page_num type:int : default:20 desc:每页数 * @param name:coll_type type:int require:1 default:-- desc:类型(1平台视频,2资料,3图文) * @return name:id type:int default:-- desc:记录id * @return name:create_at type:string default:-- desc:收藏时间 * @return name:coll_type type:int default:-- desc:收藏类型(1平台视频) * @return name:video_item type:array default:-- desc:收藏详情(coll_type=1平台视频) * @return name:video_item.video_id type:int default:-- desc:视频记录id * @return name:video_item.id type:int default:-- desc:视频详情【url_arr】id * @return name:video_item.cover type:string default:-- desc:视频详情封面 * @return name:video_item.url type:string default:-- desc:视频详情链接 * @return name:video_item.title type:string default:-- desc:视频详标题 * @return name:datum_item type:array default:-- desc:收藏详情(coll_type=2资料) * @return name:datum_item.datum_id type:int default:-- desc:资料记录id * @return name:datum_item.id type:int default:-- desc:资料详情id * @return name:datum_item.url type:string default:-- desc:资料地址 * @return name:datum_item.title type:string default:-- desc:资料标题 * @return name:article_item type:array default:-- desc:收藏详情(coll_type=3图文) * @return name:article_item.article_id type:int default:-- desc:图文记录id * @return name:article_item.id type:int default:-- desc:图文详情id * @return name:article_item.cover type:string default:-- desc:封面 * @return name:article_item.images type:string default:-- desc:图片(多张用|隔开) * @return name:article_item.content type:string default:-- desc:图文内容 */ public function getUserCollectList() { $coll_type = input('get.coll_type',1); $sel_where = []; $sel_where[] = ['coll_type','=',$coll_type]; $sel_where[] = ['user_id','=',$this->user_id]; if(!in_array($coll_type,[1,2,3])) $this->error('收藏类型有误'); $with = ['','videoItem','datumItem','articleItem']; $list = UserCollect::with($with[$coll_type]) ->field('id,create_at,coll_type') ->where($sel_where) ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 取消收藏 * @desc 取消收藏 * @author qc * @method POST * @url /api/Collect/cancelCollect * @header name:Authorization require:1 desc:Token * @param name:ids type:string : default:'' desc:需要删除的id记录(用逗号隔开) */ public function cancelCollect() { $ids = input('post.ids',''); if(!$ids) $this->error('请选择要取消收藏的记录'); UserCollect::where('id','in',$ids)->where('user_id','=',$this->user_id)->delete(); $this->success('取消成功'); } /** * @title 取消收藏 * @desc 根据类型(平台视频id||用户视频id)取消 * @author qc * @method POST * @url /api/Collect/cancelCollectByType * @header name:Authorization require:1 desc:Token * @param name:coll_type type:int require:1 default:1s desc:类型(1平台视频id,2用户视频id) * @param name:coll_id type:int default:1 desc:取消收藏的id(平台视频id||用户视频id) */ public function cancelCollectByType() { $coll_type = input('post.coll_type',1); $coll_id = input('get.coll_id',0); UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$coll_id])->delete(); $this->success('取消成功'); } }