|
@@ -169,6 +169,54 @@ class Video extends Base
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @title 获取推荐视频列表【不分页】
|
|
|
+ * @desc 获取推荐视频列表【不分页】
|
|
|
+ * @author qc
|
|
|
+ * @method GET
|
|
|
+ * @url /api/Video/getRecommendVideoList
|
|
|
+ * @header name:Authorization require:1 desc:Token
|
|
|
+ * @param name:title type:string default:-- desc:标题
|
|
|
+ */
|
|
|
+ public function getRecommendVideoList()
|
|
|
+ {
|
|
|
+ $app_name = sysconf('app_name');
|
|
|
+ $app_logo = sysconf('app_logo');
|
|
|
+ $where_str = 'id > 0';
|
|
|
+ $search_log = UserSearch::getSearchTitle($this->user_id,1);
|
|
|
+ $search_arr = [];
|
|
|
+ foreach ($search_log as $t){
|
|
|
+ $search_arr[] = " title like '".'%'.$t."%'" .' ';
|
|
|
+ }
|
|
|
+ if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
|
|
|
+ $list = VideoUrl::where($where_str)->order('id desc')->limit(0,20)->select()->toArray();
|
|
|
+ $rand_num = 0;
|
|
|
+ if(count($list) < 20)$rand_num = 20 - count($list);
|
|
|
+ if($rand_num > 0) {
|
|
|
+ $rand_list = VideoUrl::where(function ($query)use($rand_num,$list){
|
|
|
+ if(!empty($search_ids)){
|
|
|
+ $search_ids = array_column($list,'id');
|
|
|
+ $all_ids = VideoUrl::where(['is_deleted'=>0])->where('id not in '.implode(',',$search_ids))->column('id,title','id');
|
|
|
+ $rand_ids = array_keys($all_ids);
|
|
|
+ if(count($all_ids) > $rand_num) $rand_ids = array_rand($all_ids,$rand_num);
|
|
|
+ return $query->where('id','in',implode(',',$rand_ids));
|
|
|
+ }
|
|
|
+ })->limit(0,$rand_num)->toArray();
|
|
|
+ if(!empty($rand_list)) $list = array_merge($list,$rand_list);
|
|
|
+ }
|
|
|
+
|
|
|
+ array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
|
|
|
+ $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,1,$v['video_id'],$v['id']);
|
|
|
+ $v['label_name'] = explode(',',trim($v['label'],','));
|
|
|
+ $v['app_name'] = $app_name;
|
|
|
+ $v['app_logo'] = $app_logo;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* @title 获取视频详情(平台)
|
|
|
* @desc 获取视频详情
|
|
|
* @author qc
|