Video.php 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\SeriesVideoCate;
  4. use app\common\model\User;
  5. use app\common\model\UserCollect;
  6. use app\common\model\UserLearn;
  7. use app\common\model\UserLevelRank;
  8. use app\common\model\UserMessage;
  9. use app\common\model\UserSearch;
  10. use app\common\model\UserTrack;
  11. use app\common\model\UserVideo;
  12. use app\common\model\VideoCate;
  13. use app\common\model\VideoComment;
  14. use app\common\model\VideoCommentLike;
  15. use app\common\model\VideoIntro;
  16. use app\common\model\VideoLabel;
  17. use app\common\model\VideoUrl;
  18. use library\tools\Data;
  19. use think\Db;
  20. /**
  21. * @title 视频
  22. * @controller Video
  23. * @group base
  24. */
  25. class Video extends Base
  26. {
  27. // 需要登录的
  28. protected $need_login = [
  29. 'userReferVideo',
  30. 'userReferVideoDetail',
  31. 'delUserVideo',
  32. 'videoComment',
  33. 'secondCommend',
  34. 'videoTags',
  35. 'videoTransmit',
  36. 'getMyVideoList',
  37. 'delComment',
  38. 'getLearnHistory',
  39. 'getReplayComment',
  40. 'getReplyVideo',
  41. 'getPurchaseVideo',
  42. 'getVideoCollect',
  43. 'getTagsVideo',
  44. ];
  45. public function initialize()
  46. {
  47. parent::initialize();
  48. parent::setUid();
  49. }
  50. /**
  51. * @title 视频接口说明
  52. * @desc 视频接口说明
  53. * @author qc
  54. * @url /api/Video/classIntro
  55. * @method GET
  56. * @return name:1 type:string default:-- desc:视频播放改DRM加密,请勿用视频地址【url】播放,这个字段弃用!!
  57. * @return name:2 type:string default:-- desc:ali_vid视频点播id,阿里云视频点播用
  58. */
  59. public function classIntro(){}
  60. /**
  61. * @title 获取分类
  62. * @desc 获取分类(共两级)
  63. * @author qc
  64. * @url /api/Video/getCateTree
  65. * @method GET
  66. * @header name:Authorization require:1 desc:Token
  67. * @param name:type type:int default:0 desc:类型1单个2系列
  68. * @return name:id type:int default:-- desc:分类id
  69. * @return name:logo type:string default:-- desc:图标
  70. * @return name:title type:string default:0 desc:分类名称
  71. * @return name:children type:array default:0 desc:下级分类
  72. */
  73. public function getCateTree()
  74. {
  75. $type = input('type',1);
  76. if($type == 1) {
  77. $list = VideoCate::where(['is_deleted'=>0])->field('id,logo,title,pid')->order('sort desc')->select()->toArray();
  78. }else{
  79. $list = SeriesVideoCate::where(['is_deleted'=>0])->field('id,logo,title,pid')->order('sort desc')->select()->toArray();
  80. }
  81. $list = make_tree($list);
  82. $this->success('ok',['list'=>$list]);
  83. }
  84. /**
  85. * @title 获取视频标签
  86. * @desc 获取视频标签
  87. * @author qc
  88. * @url /api/Video/getVideoLabel
  89. * @method GET
  90. * @header name:Authorization require:1 desc:Token
  91. * @return name:id type:int default:-- desc:id
  92. * @return name:title type:string default:0 desc:标题
  93. */
  94. public function getVideoLabel()
  95. {
  96. $list = VideoLabel::field('id,title')->where(['is_deleted'=>0,'status'=>1])->select()->toArray();
  97. $this->success('',['list'=>$list]);
  98. }
  99. /**
  100. * @title 视频推荐
  101. * @desc 视频推荐
  102. * @author qc
  103. * @method GET
  104. * @url /api/Video/getRecommendList
  105. * @header name:Authorization require:1 desc:Token
  106. * @param name:page type:int default:0 desc:页数
  107. * @param name:page_num type:int default:20 desc:每页数
  108. * @return name:id type:string default:-- desc:视频url_id
  109. * @return name:title type:string default:-- desc:标题
  110. * @return name:video_id type:string default:-- desc:系列id
  111. * @return name:cover type:string default:-- desc:封面
  112. * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是)
  113. * @return name:app_name type:string default:-- desc:平台名称
  114. * @return name:app_logo type:string default:-- desc:平台头像
  115. */
  116. public function getRecommendList()
  117. {
  118. $app_name = sysconf('app_name');
  119. $app_logo = sysconf('app_logo');
  120. $search_log = UserSearch::getSearchTitle($this->user_id,1);
  121. $search_arr = [];
  122. $where_str = 'b.id > 0';
  123. foreach ($search_log as $t){
  124. $search_arr[] = " b.title like '".'%'.$t."%'" .' ';
  125. $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
  126. }
  127. if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
  128. $field = ' a.id,a.title,a.cover,a.user_id,a.is_vip,a.ali_vid,a.video_id ,IFNULL(is_recommend,0) is_recommend ';
  129. $table = 'dd_video_url';
  130. $order_by_two = 'id';
  131. $sql = "SELECT $field FROM " .$table . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM $table b WHERE ( $where_str )) AS c ON c.id = a.id Left JOIN dd_video_intro as k ON a.video_id = k.id WHERE a.is_deleted = 0 AND a.status =1 AND k.is_deleted = 0 AND k.status = 1 ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}";
  132. $list = Db::query($sql);
  133. array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
  134. if(!$v['user_id']){
  135. $v['app_name'] = $app_name;
  136. $v['app_logo'] = $app_logo;
  137. }else{
  138. $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
  139. $v['app_name'] = $user_info ? $user_info->name : '';
  140. $v['app_logo'] = $user_info ? $user_info->headimg : '';
  141. }
  142. });
  143. $this->success('ok',['list'=>$list,'sql'=>$sql]);
  144. }
  145. /**
  146. * @title 获取视频列表(平台发布)
  147. * @desc 获取视频列表
  148. * @author qc
  149. * @method GET
  150. * @url /api/Video/getVideoList
  151. * @header name:Authorization require:1 desc:Token
  152. * @param name:type type:int default:0 desc:类型0全部1单个2系列
  153. * @param name:is_tj type:int default:0 desc:是否推荐0否1是
  154. * @param name:is_hot type:int default:-1 desc:是否置顶0否1是(-1全部)
  155. * @param name:title type:string default:-- desc:标题
  156. * @param name:first_classify type:int default:0 desc:视频一级分类
  157. * @param name:second_classify type:int default:0 desc:视频二级分类
  158. * @param name:page type:int default:0 desc:页数
  159. * @param name:page_num type:int default:20 desc:每页数
  160. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  161. * @return name:id type:string default:-- desc:ID[请求/api/Video/getVideoDetail用]
  162. * @return name:title type:string default:-- desc:标题
  163. * @return name:cover type:string default:-- desc:封面
  164. * @return name:video_url type:string default:-- desc:视频地址
  165. * @return name:first_classify type:int default:-- desc:视频一级分类
  166. * @return name:second_classify type:int default:-- desc:视频二级分类
  167. * @return name:is_top type:int default:-- desc:是否置顶(0否,1是)
  168. * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是)
  169. * @return name:is_over type:int default:-- desc:是否完结(0否,1是)
  170. * @return name:label_name type:array default:-- desc:标签
  171. * @return name:read_num type:int default:-- desc:播放量
  172. * @return name:total_num type:int default:-- desc:总数量
  173. * @return name:is_collect type:int default:-- desc:是否收藏
  174. * @return name:app_name type:string default:-- desc:平台名称
  175. * @return name:app_logo type:string default:-- desc:平台头像
  176. * @return name:video_arr type:array default:-- desc:视频地址
  177. * @return name:video_arr.url type:string default:-- desc:视频地址
  178. */
  179. public function getVideoList()
  180. {
  181. $sel_where = [];
  182. $sel_where[] = ['is_deleted','=',0];
  183. $sel_where[] = ['status','=',1];
  184. $sel_where[] = ['url_num','>=',1];
  185. $title = input('get.title');
  186. $type = input('get.type',0);
  187. $is_hot = input('get.is_hot',-1);
  188. $first_classify = input('get.first_classify');
  189. $second_classify = input('get.second_classify');
  190. $sort_type = input('get.sort_type',1);
  191. $is_tj = input('get.is_tj',0);
  192. $app_name = sysconf('app_name');
  193. $app_logo = sysconf('app_logo');
  194. if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,1);
  195. if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
  196. if($first_classify) $sel_where[] = ['first_classify','=',$first_classify];
  197. if($second_classify) $sel_where[] = ['second_classify','=',$second_classify];
  198. if($type) $sel_where[] = ['type','=',$type];
  199. if($is_hot >= 0) $sel_where[] = ['is_hot','=',$is_hot];
  200. $where_str = 'id > 0';
  201. switch ($sort_type) {
  202. case 1:
  203. $order = ['is_top'=>'desc','sort'=>'desc','id'=>'desc'];
  204. break;
  205. case 2:
  206. $order = ['id'=>'asc','sort'=>'desc'];
  207. break;
  208. case 3:
  209. $order = ['id'=>'desc','sort'=>'desc'];
  210. break;
  211. }
  212. $total_num =VideoIntro::where($sel_where)->where($where_str)->count();
  213. $list = VideoIntro::with(['videoArr'])->where($sel_where)
  214. ->where($where_str)
  215. ->order($order)
  216. ->limit($this->off_set,$this->page_num)->select()->toArray();
  217. array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
  218. $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,1,$v['id']);
  219. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  220. $v['read_num'] = array_sum(array_column($v['video_arr'],'read_num'));
  221. $v['app_name'] = $app_name;
  222. $v['app_logo'] = $app_logo;
  223. });
  224. $this->success('ok',['list'=>$list,'total_num'=>$total_num]);
  225. }
  226. /**
  227. * @title 获取推荐视频列表【不分页】【弃用】
  228. * @desc 获取推荐视频列表【不分页】
  229. * @author qc
  230. * @method GET
  231. * @url /api/Video/getRecommendVideoList
  232. * @header name:Authorization require:1 desc:Token
  233. * @return name:id type:string default:-- desc:id
  234. * @return name:title type:string default:-- desc:标题
  235. * @return name:cover type:string default:-- desc:预览图
  236. * @return name:transmit_num type:int default:-- desc:转发量
  237. * @return name:read_num type:int default:-- desc:播放量
  238. * @return name:is_vip type:int default:-- desc:是否是需要会员(0否1是)
  239. * @return name:ppt type:string default:-- desc:关联ppt链接
  240. * @return name:ali_vid type:string default:-- desc:阿里云点播id
  241. * @return name:app_name type:string default:-- desc:平台名称
  242. * @return name:app_logo type:string default:-- desc:平台头像
  243. */
  244. public function getRecommendVideoList()
  245. {
  246. $app_name = sysconf('app_name');
  247. $app_logo = sysconf('app_logo');
  248. $where_str = 'id > 0';
  249. $sel_where = [];
  250. $sel_where[] = ['is_deleted','=',0];
  251. $sel_where[] = ['status','=',1];
  252. $search_log = UserSearch::getSearchTitle($this->user_id,1);
  253. $search_arr = [];
  254. foreach ($search_log as $t){
  255. $search_arr[] = " title like '".'%'.$t."%'" .' ';
  256. }
  257. if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
  258. $list = VideoUrl::field('id,video_id,title,cover,ali_vid,ppt,is_vip,read_num')
  259. ->where($where_str)->where($sel_where)->order('id desc')->limit(0,20)->select()->toArray();
  260. $rand_num = 0;
  261. if(count($list) < 20)$rand_num = 20 - count($list);
  262. if($rand_num > 0) {
  263. $rand_list = VideoUrl::field('id,video_id,title,cover,ali_vid,ppt,is_vip,read_num')->where(function ($query)use($rand_num,$list){
  264. if(!empty($search_ids)){
  265. $search_ids = array_column($list,'id');
  266. $all_ids = VideoUrl::where(['is_deleted'=>0])->where('id not in '.implode(',',$search_ids))->column('id,title','id');
  267. $rand_ids = array_keys($all_ids);
  268. if(count($all_ids) > $rand_num) $rand_ids = array_rand($all_ids,$rand_num);
  269. return $query->where('id','in',implode(',',$rand_ids));
  270. }
  271. })->where($sel_where)->limit(0,$rand_num)->select()->toArray();
  272. if(!empty($rand_list)) $list = array_merge($list,$rand_list);
  273. }
  274. array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
  275. $v['app_name'] = $app_name;
  276. $v['app_logo'] = $app_logo;
  277. });
  278. $this->success('ok',$list);
  279. }
  280. /**
  281. * @title 视频搜索
  282. * @desc 视频搜索
  283. * @author qc
  284. * @method GET
  285. * @url /api/Video/videoSearch
  286. * @header name:Authorization require:1 desc:Token
  287. * @param name:title type:string default:1 desc:标题
  288. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  289. * @param name:page type:int default:0 desc:页数
  290. * @param name:page_num type:int default:20 desc:每页数
  291. * @return name:title type:string default:-- desc:标题
  292. * @return name:cover type:string default:-- desc:预览图
  293. * @return name:transmit_num type:int default:-- desc:转发量
  294. * @return name:read_num type:int default:-- desc:播放量
  295. * @return name:is_vip type:int default:-- desc:是否是需要会员(0否1是)
  296. * @return name:ali_vid type:string default:-- desc:阿里云点播id
  297. * @return name:app_name type:string default:-- desc:平台名称
  298. * @return name:app_logo type:string default:-- desc:平台头像
  299. */
  300. public function videoSearch()
  301. {
  302. $title = input('get.title');
  303. $sort_type = input('get.sort_type',1);
  304. if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,1);
  305. $sel_where = [];
  306. $sel_where[] = ['a.is_deleted','=',0];
  307. $sel_where[] = ['a.status','=',1];
  308. $sel_where[] = ['b.is_deleted','=',0];
  309. $sel_where[] = ['b.status','=',1];
  310. if($title) $sel_where[] = ['a.title|a.label','like','%'.$title.'%'];
  311. $app_name = sysconf('app_name');
  312. $app_logo = sysconf('app_logo');
  313. switch ($sort_type) {
  314. case 1:
  315. $order = ['a.id'=>'desc'];
  316. break;
  317. case 2:
  318. $order = ['a.id'=>'asc','a.sort'=>'desc'];
  319. break;
  320. case 3:
  321. $order = ['a.id'=>'desc','a.sort'=>'desc'];
  322. break;
  323. }
  324. $list = VideoUrl::field('a.id,a.video_id,a.title,a.cover,a.ali_vid,a.ppt,a.is_vip,a.read_num')
  325. ->alias('a')
  326. ->leftJoin('VideoIntro b','a.video_id = b.id')
  327. ->where($sel_where)->order($order)
  328. ->limit($this->off_set,$this->page_num)->select()->toArray();
  329. array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
  330. $v['app_name'] = $app_name;
  331. $v['app_logo'] = $app_logo;
  332. });
  333. $this->success('ok',$list);
  334. }
  335. /**
  336. * @title 获取视频详情(平台)
  337. * @desc 获取视频详情
  338. * @author qc
  339. * @method GET
  340. * @url /api/Video/getVideoDetail
  341. * @header name:Authorization require:1 desc:Token
  342. * @param name:id type:int default:0 desc:视频id
  343. * @return name:title type:string default:-- desc:标题
  344. * @return name:cover type:string default:-- desc:封面
  345. * @return name:video_url type:string default:-- desc:视频地址
  346. * @return name:first_classify type:int default:-- desc:视频一级分类
  347. * @return name:is_top type:int default:-- desc:是否置顶(0否,1是)
  348. * @return name:read_num type:int default:-- desc:播放量
  349. * @return name:video_arr type:array default:-- desc:视频地址
  350. * @return name:video_arr.id type:int default:-- desc:ID[请求视频模块其他接口参数:url_id]
  351. * @return name:video_arr.cover type:string default:-- desc:预览图
  352. * @return name:video_arr.url type:string default:-- desc:视频地址
  353. * @return name:video_arr.transmit_num type:int default:-- desc:转发量
  354. * @return name:video_arr.read_num type:int default:-- desc:播放量
  355. * @return name:video_arr.is_vip type:int default:-- desc:是否是需要会员(0否1是)
  356. * @return name:video_arr.is_collect type:int default:-- desc:是否收藏
  357. * @return name:video_arr.collect_num type:int default:-- desc:收藏量
  358. * @return name:video_arr.praise_num type:int default:-- desc:点赞量
  359. * @return name:video_arr.is_praise type:int default:-- desc:是否点赞
  360. * @return name:video_arr.article_id type:int default:-- desc:关联视频id【单个id||系列id】
  361. * @return name:video_arr.article_item type:int default:-- desc:关联视频详情id【item_list.id】
  362. * @return name:video_arr.datum_id type:int default:-- desc:资料id【单个id||系列id】
  363. * @return name:video_arr.datum_item type:int default:-- desc:资料详情id【url_arr.id】
  364. * @return name:video_arr.ppt type:string default:-- desc:关联ppt链接
  365. * @return name:video_arr.ali_vid type:string default:-- desc:阿里云点播id
  366. */
  367. public function getVideoDetail()
  368. {
  369. $sel_where = [];
  370. $sel_where[] = ['id','=',input('get.id')];
  371. $detail = VideoIntro::with(['videoArr'])->where($sel_where)->find()->toArray();
  372. if($detail['is_deleted'] == 1 || $detail['status'] == 0)$this->error('该视频已下线');
  373. $detail['label_name'] = [];
  374. if($detail['label']) {
  375. $detail['label_name'] = explode(',',trim($detail['label'],','));
  376. }
  377. $level_id = UserLevelRank::getUserVip($this->user_id);
  378. foreach ($detail['video_arr'] as &$dv) {
  379. if($dv['is_vip'] && !$level_id) $dv['url'] = '';
  380. $dv['is_collect'] = UserCollect::checkCollectByType($this->user_id,1,$detail['id'],$dv['id']);
  381. // $dv['collect_num'] = UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>1,'coll_id'=>$detail['id'],'children_id'=>$dv['id']])->count();
  382. $dv['collect_num'] = UserCollect::getCollectNum(1,$detail['id'],$dv['id']);
  383. $dv['is_praise'] = VideoCommentLike::where(['user_id'=>$this->user_id,'type'=>2,'like_id'=>$dv['id']])->count();
  384. $dv['praise_num'] = VideoCommentLike::where(['type'=>2,'like_id'=>$dv['id']])->count();
  385. }
  386. $detail['read_num'] = array_sum(array_column($detail['video_arr'],'read_num'));
  387. $this->success('ok',['detail'=>$detail]);
  388. }
  389. /**
  390. * @title 获取视频列表(用户发布【审核通过的】)
  391. * @desc 用户发布【审核通过的】
  392. * @author qc
  393. * @method GET
  394. * @url /api/Video/getUserVideoList
  395. * @header name:Authorization require:1 desc:Token
  396. * @param name:title type:string default:-- desc:标题
  397. * @param name:first_classify type:int default:0 desc:视频一级分类
  398. * @param name:second_classify type:int default:0 desc:视频二级分类
  399. * @param name:page type:int default:0 desc:页数
  400. * @param name:page_num type:int default:20 desc:每页数
  401. * @return name:title type:string default:-- desc:标题
  402. * @return name:cover type:string default:-- desc:封面
  403. * @return name:video_url type:string default:-- desc:视频地址
  404. * @return name:first_classify type:int default:-- desc:视频一级分类
  405. * @return name:second_classify type:int default:-- desc:视频二级分类
  406. * @return name:read_num type:int default:-- desc:播放量
  407. * @return name:is_collect type:int default:-- desc:是否收藏
  408. */
  409. public function getUserVideoList()
  410. {
  411. $sel_where = [];
  412. $sel_where[] = ['is_deleted','=',0];
  413. $sel_where[] = ['status','=',1];
  414. $title = input('get.title');
  415. $first_classify = input('get.first_classify');
  416. $second_classify = input('get.second_classify');
  417. if($title) $sel_where[] = ['v.title|v.label','like','%'.$title.'%'];
  418. if($first_classify) $sel_where[] = ['v.first_classify','=',$first_classify];
  419. if($second_classify) $sel_where[] = ['v.second_classify','=',$second_classify];
  420. $list = UserVideo::field('v.*')->where($sel_where)->order('v.id desc')
  421. ->alias('v')
  422. ->leftJoin('User u','u.id = v.user_id')
  423. ->limit($this->off_set,$this->page_num)
  424. ->select()->toArray();
  425. $this->success('ok',['list'=>$list]);
  426. }
  427. /**
  428. * @title 获取我的视频列表
  429. * @desc 获取我的视频列表
  430. * @author qc
  431. * @method GET
  432. * @url /api/Video/getMyVideoList
  433. * @header name:Authorization require:1 desc:Token
  434. * @param name:title type:string default:-- desc:标题
  435. * @param name:page type:int default:0 desc:页数
  436. * @param name:page_num type:int default:20 desc:每页数
  437. * @return name:title type:string default:-- desc:标题
  438. * @return name:cover type:string default:-- desc:封面
  439. * @return name:video_url type:string default:-- desc:视频地址
  440. * @return name:first_classify type:int default:-- desc:视频一级分类
  441. * @return name:second_classify type:int default:-- desc:视频二级分类
  442. * @return name:read_num type:int default:-- desc:播放量
  443. * @return name:is_collect type:int default:-- desc:是否收藏
  444. * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
  445. */
  446. public function getMyVideoList()
  447. {
  448. $sel_where = [];
  449. $sel_where[] = ['is_deleted','=',0];
  450. $sel_where[] = ['user_id','=',$this->user_id];
  451. $title = input('get.title');
  452. if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
  453. $list = UserVideo::where($sel_where)->order('id desc')
  454. ->limit($this->off_set,$this->page_num)
  455. ->select()->toArray();
  456. $this->success('ok',['list'=>$list]);
  457. }
  458. /**
  459. * @title 获取视频详情(会员)
  460. * @desc 获取视频详情
  461. * @author qc
  462. * @method GET
  463. * @url /api/Video/getUserVideoDetail
  464. * @header name:Authorization require:1 desc:Token
  465. * @param name:id type:int default:0 desc:视频id
  466. * @param name:first_classify type:int default:0 desc:视频一级分类
  467. * @param name:second_classify type:int default:0 desc:视频二级分类
  468. * @param name:page type:int default:0 desc:页数
  469. * @param name:page_num type:int default:20 desc:每页数
  470. * @return name:title type:string default:-- desc:标题
  471. * @return name:cover type:string default:-- desc:封面
  472. * @return name:video_url type:string default:-- desc:视频地址
  473. * @return name:first_classify type:int default:-- desc:视频一级分类
  474. * @return name:second_classify type:int default:-- desc:视频二级分类
  475. * @return name:read_num type:int default:-- desc:播放量
  476. * @return name:is_collect type:int default:-- desc:是否收藏
  477. * @return name:collect_num type:int default:-- desc:收藏量
  478. * @return name:praise_num type:int default:-- desc:点赞量
  479. * @return name:is_praise type:int default:-- desc:是否点赞
  480. * @return name:transmit_num type:int default:-- desc:转发量
  481. */
  482. public function getUserVideoDetail()
  483. {
  484. $detail = UserVideo::where('id',input('get.id'))->find();
  485. if(!$detail)$this->error('该视频已下线');
  486. if($detail->status != 1)$this->error('该视频未通过审核');
  487. $detail->is_collect = 0;
  488. $detail->collect_num = 0;
  489. $detail->is_praise =0;
  490. $detail->praise_num = 0;
  491. $this->success('ok',['detail'=>$detail->toArray()]);
  492. }
  493. /**
  494. * @title 用户提交或修改视频
  495. * @desc 用户提交或修改视频
  496. * @author qc
  497. * @method POST
  498. * @url /api/Video/userReferVideo
  499. * @header name:Authorization require:1 desc:Token
  500. * @param name:id type:int default:-- desc:id(修改时必传)
  501. * @param name:title type:string default:-- desc:标题
  502. * @param name:video_url type:string default:-- desc:视频地址
  503. * @param name:desc type:string default:-- desc:简介
  504. * @param name:first_classify type:int default:-- desc:视频一级分类id
  505. * @param name:second_classify type:int default:-- desc:视频二级分类id
  506. * @param name:label type:string default:-- desc:视频标签id(多个用逗号隔开)
  507. */
  508. public function userReferVideo()
  509. {
  510. $id = input('post.id',0);
  511. $title = input('post.title');
  512. $desc = input('post.desc');
  513. $video_url = input('post.video_url');
  514. $cover = $video_url.'?x-oss-process=video/snapshot,t_2000,m_fast';
  515. $first_classify = input('post.first_classify',0);
  516. $second_classify = input('post.second_classify',0);
  517. $label = input('post.label');
  518. if(!$video_url) $this->error('请上传视频');
  519. if($id){
  520. $check_status = UserVideo::where('id',$id)->value('status');
  521. if($check_status == 1) $this->error('视频已审核通过,不允许修改');
  522. }
  523. $data = [
  524. 'title' => $title,
  525. 'cover' => $cover,
  526. 'user_id' => $this->user_id,
  527. 'desc' => $desc,
  528. 'first_classify' => $first_classify,
  529. 'second_classify' => $second_classify,
  530. 'video_url' => $video_url,
  531. 'label' => $label,
  532. 'status' => 0,
  533. 'remark' => '',
  534. ];
  535. if($id) $data['id'] = $id;
  536. if($id){
  537. UserVideo::where('id',$id)->update($data);
  538. }else{
  539. $res= UserVideo::create($data) ;
  540. }
  541. UserMessage::sendUserMessage($this->user_id,'video',1,0,0,$id ? $id:$res->id);
  542. $this->success('提交成功,请等待审核',['id'=> $id ? :$res->id]);
  543. }
  544. /**
  545. * @title 获取用户提交视频详情
  546. * @desc 获取用户提交视频详情
  547. * @author qc
  548. * @method GET
  549. * @url /api/Video/userReferVideoDetail
  550. * @header name:Authorization require:1 desc:Token
  551. * @param name:id type:int default:-- desc:id
  552. * @return name:title type:string default:-- desc:标题
  553. * @return name:cover type:string default:-- desc:封面
  554. * @return name:video_url type:string default:-- desc:视频地址
  555. * @return name:first_classify type:int default:-- desc:视频一级分类id
  556. * @return name:second_classify type:int default:-- desc:视频二级分类id
  557. * @return name:label type:string default:-- desc:视频标签id(多个用逗号隔开)
  558. */
  559. public function userReferVideoDetail()
  560. {
  561. $detail = UserVideo::where('id',input('get.id'))->find()->toArray();
  562. if($detail['is_deleted'] == 1) $this->error('视频已删除');
  563. $detail['label_name'] = [];
  564. if($detail['label']) {
  565. $detail['label_name'] =explode(',',trim($detail['label'],','));
  566. }
  567. $this->success('获取成功',['detail'=>$detail]);
  568. }
  569. /**
  570. * @title 用户删除视频记录
  571. * @desc 用户删除视频记录
  572. * @author qc
  573. * @method POST
  574. * @url /api/Video/delUserVideo
  575. * @header name:Authorization require:1 desc:Token
  576. * @param name:id type:int default:-- desc:id
  577. */
  578. public function delUserVideo()
  579. {
  580. UserVideo::where(['user_id'=>$this->user_id,'id'=>input('post.id')])->delete();
  581. $this->success('删除成功');
  582. }
  583. /**
  584. * @title 视频评论
  585. * @desc 视频评论
  586. * @author qc
  587. * @method POST
  588. * @url /api/Video/videoComment
  589. * @header name:Authorization require:1 desc:Token
  590. * @param name:video_type type:int default:1 desc:视频类型(1平台2会员)
  591. * @param name:video_id type:int default:-- desc:视频id
  592. * @param name:url_id type:int default:-- desc:平台类型必传
  593. * @param name:content type:string default:-- desc:内容
  594. */
  595. public function videoComment()
  596. {
  597. $video_type = input('post.video_type',1);
  598. $video_id = input('post.video_id');
  599. $url_id = input('post.url_id',0);
  600. $content = input('post.content',0);
  601. if(!$content) $this->error('请输入评论内容');
  602. $res = VideoComment::create(['user_id'=>$this->user_id,'content'=>$content,'video_id'=>$video_id,'url_id'=>$url_id,'video_type'=>$video_type]);;
  603. $detail =VideoComment::where('c.id',$res->id)
  604. ->alias('c')
  605. ->field('c.id,c.content,c.user_id,c.create_at,u.name,u.headimg')
  606. ->leftJoin('store_member u','u.id = c.user_id')
  607. ->find()->toArray();
  608. $send_user = VideoUrl::where('id',$url_id)->value('user_id');
  609. $user_info = $this->userInfo('name');
  610. if($send_user) UserMessage:: sendUserMessage($send_user,'video',4,0,$this->user_id,$url_id,$user_info['name'].'评论了您的视频');
  611. $this->success('评论成功',['detail'=>$detail]);
  612. }
  613. /**
  614. * @title 视频二级评论
  615. * @desc 视频二级评论
  616. * @author qc
  617. * @method POST
  618. * @url /api/Video/secondCommend
  619. * @header name:Authorization require:1 desc:Token
  620. * @param name:id type:int default:1 desc:评论id
  621. * @param name:content type:string default:-- desc:内容
  622. * @return name:name type:string default:-- desc:会员名称
  623. * @return name:headimg type:string default:-- desc:会员头像
  624. * @return name:content type:string default:-- desc:内容
  625. */
  626. public function secondCommend()
  627. {
  628. $comment = VideoComment::where('id',input('post.id'))->find()->toArray();
  629. $user_info = $this->userInfo('name');
  630. UserMessage:: sendUserMessage($comment['user_id'],'video',3,0,$this->user_id,$comment['id'],$user_info['name'].'回复了您的评论');
  631. $send_user = VideoUrl::where('id',$comment['url_id'])->value('user_id');
  632. if($send_user) UserMessage:: sendUserMessage($send_user,'video',4,0,$this->user_id,$comment['url_id'],$user_info['name'].'评论了您的视频');
  633. unset($comment['id']);
  634. unset($comment['create_at']);
  635. $comment['pid'] = input('post.id');
  636. $comment['user_id'] = $this->user_id;
  637. $comment['content'] = input('post.content');
  638. $comment['lev']++;
  639. if(!$comment['source_id']) $comment['source_id'] = input('post.id');
  640. $res = VideoComment::create($comment);
  641. $detail = VideoComment::where('c.id',$res->id)
  642. ->alias('c')
  643. ->field('c.id,c.content,c.create_at,u.name,u.headimg')
  644. ->leftJoin('store_member u','u.id = c.user_id')
  645. ->find()->toArray();
  646. $this->success('评论成功',['detail'=>$detail]);
  647. }
  648. /**
  649. * @title 获取视频评论列表
  650. * @desc 获取视频评论列表
  651. * @author qc
  652. * @method GET
  653. * @url /api/Video/getVideoCommentList
  654. * @header name:Authorization require:1 desc:Token
  655. * @param name:video_type type:int default:1 desc:视频类型(1平台2会员)
  656. * @param name:video_id type:int default:-- desc:视频id
  657. * @param name:url_id type:int default:-- desc:url_id
  658. * @param name:sort_type type:int default:1 desc:排序规则1时间2热点
  659. * @param name:page type:int default:1 desc:页数
  660. * @param name:page_num type:int default:20 desc:每页数
  661. * @return name:name type:string default:-- desc:会员名称
  662. * @return name:headimg type:string default:-- desc:会员头像
  663. * @return name:content type:string default:-- desc:内容
  664. * @return name:parent type:array default:-- desc:评论上一级(数据同上【一维数组】)
  665. * @return name:children type:array default:-- desc:二级评论(数据同上【二维数组】)
  666. * @return name:like_num type:int default:-- desc:点赞数量
  667. * @return name:is_like type:int default:-- desc:是否点赞(0否1是)
  668. * @return name:can_delete type:int default:-- desc:是否可以删除(0否1是)
  669. * @return name:total_num type:int default:-- desc:总评论数(仅一级)
  670. *
  671. */
  672. public function getVideoCommentList()
  673. {
  674. $where = [];
  675. $where[] = ['c.video_id','=',input('get.video_id')];
  676. $where[] = ['c.url_id','=',input('get.url_id')];
  677. $where[] = ['c.video_type','=',input('get.video_type')];
  678. $where[] = ['c.is_deleted','=',0];
  679. $user_id = $this->user_id;
  680. $sort_type= input('sort_type',1);
  681. switch ($sort_type) {
  682. case 1:
  683. $order = ['c.id'=>'desc','c.like_times'=>'desc'];
  684. break;
  685. case 2:
  686. $order = ['c.like_times'=>'desc','c.id'=>'desc'];
  687. break;
  688. }
  689. $list =VideoComment::where($where)
  690. ->alias('c')
  691. ->field('c.*,u.name,u.headimg')
  692. ->leftJoin('store_member u','u.id = c.user_id')
  693. ->order($order)
  694. ->limit($this->off_set,$this->page_num)
  695. ->select()->toArray();
  696. array_walk($list,function (&$val,$k)use($user_id){
  697. $children = VideoComment::where(['c.pid'=>$val['id'],'c.is_deleted'=>0])
  698. ->alias('c')
  699. ->field('c.*,u.name,u.headimg')
  700. ->leftJoin('store_member u','u.id = c.user_id')
  701. ->order('c.id asc')
  702. ->select()->toArray();
  703. $val['like_num'] = VideoCommentLike::where('like_id',$val['id'])->where('type',1)->count();
  704. $val['children'] = $children;
  705. $val['is_like'] = VideoCommentLike::where(['like_id'=>$val['id'],'user_id'=>$user_id,'type'=>1])->count();
  706. $parent = VideoComment::where(['c.id'=>$val['pid'],'c.is_deleted'=>0])
  707. ->alias('c')->field('c.*,u.name,u.headimg')
  708. ->leftJoin('store_member u','u.id = c.user_id')
  709. ->find();
  710. $val['parent'] = $parent ? $parent->toArray() : null;
  711. $val['can_delete'] = $val['user_id'] == $this->user_id ? 1 :0;
  712. });
  713. $total_num = VideoComment::where($where)->alias('c')->count();
  714. $this->success('ok',['list'=>$list,'total_num'=>$total_num]);
  715. }
  716. /**
  717. * @title 删除评论
  718. * @desc 删除评论
  719. * @author qc
  720. * @method POST
  721. * @url /api/Video/delComment
  722. * @header name:Authorization require:1 desc:Token
  723. * @param name:id type:int default:1 desc:评论id
  724. */
  725. public function delComment(){
  726. VideoComment::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->update(['is_deleted'=>1]);
  727. $this->success('删除成功');
  728. }
  729. /**
  730. * @title 点赞||取消点赞
  731. * @desc 点赞||取消点赞
  732. * @author qc
  733. * @method POST
  734. * @url /api/Video/videoTags
  735. * @header name:Authorization require:1 desc:Token
  736. * @param name:type type:int default:1 desc:1评论点赞,评论记录id,2平台视频点赞
  737. * @param name:like_id type:int default:1 desc:点赞id【二级评论不要这个功能】(平台视频点赞用video_arr的iD)
  738. * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
  739. */
  740. public function videoTags()
  741. {
  742. $type = input('post.type',1);
  743. $like_id = input('post.like_id');
  744. $ret_val = 0;
  745. $check_tags = VideoCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type])->value('id');
  746. if($check_tags) {
  747. VideoCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type])->delete();
  748. if($type == 1) VideoComment::where('id',$like_id)->setDec('like_times');
  749. }else{
  750. Data::save('VideoCommentLike',
  751. ['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type],'user_id',
  752. ['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type]);
  753. $ret_val = 1;
  754. if($type == 1) VideoComment::where('id',$like_id)->setInc('like_times');
  755. }
  756. $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
  757. }
  758. /**
  759. * @title 视频转发(转发数量统计)
  760. * @desc 转发成功后调用
  761. * @author qc
  762. * @method POST
  763. * @url /api/Video/videoTransmit
  764. * @header name:Authorization require:1 desc:Token
  765. * @param name:video_type type:int default:1 desc:视频类型(1平台2会员)
  766. * @param name:video_id type:int default:-- desc:视频id
  767. * @param name:url_id type:int default:-- desc:平台类型必传
  768. */
  769. public function videoTransmit()
  770. {
  771. $video_type = input('post.video_type',1);
  772. $video_id = input('post.video_id');
  773. $url_id = input('post.url_id',0);
  774. if($video_type == 1) {
  775. VideoUrl::where('id',$url_id)->setInc('transmit_num');
  776. }else{
  777. UserVideo::where('id',$video_id)->setInc('transmit_num');
  778. }
  779. $this->success('ok');
  780. }
  781. /**
  782. * @title 视频播放(播放数量统计)
  783. * @desc 播放数量统计
  784. * @author qc
  785. * @method POST
  786. * @url /api/Video/videoPlay
  787. * @header name:Authorization require:1 desc:Token
  788. * @param name:video_id type:int default:-- desc:视频id
  789. * @param name:url_id type:int default:-- desc:url_id
  790. */
  791. public function videoPlay()
  792. {
  793. $video_id = input('post.video_id');
  794. $url_id = input('post.url_id',0);
  795. VideoUrl::where('id',$url_id)->setInc('read_num');
  796. if(!$video_id) $video_id = VideoUrl::where('id',$url_id)->value('video_id');
  797. UserTrack::crateTrack($this->user_id,1,$video_id,$url_id);
  798. $this->success('ok');
  799. }
  800. /**
  801. * @title 以下接口学习服务模块的
  802. * @desc
  803. * @author qc
  804. * @method
  805. * @url /api/Video/learn()
  806. */
  807. public function learn(){}
  808. /**
  809. * @title 视频学习历史
  810. * @desc 视频学习历史
  811. * @author qc
  812. * @method GET
  813. * @url /api/Video/getLearnHistory
  814. * @header name:Authorization require:1 desc:Token
  815. * @param name:title type:string default:-- desc:标题
  816. * @param name:page type:int default:0 desc:页数
  817. * @param name:page_num type:int default:20 desc:每页数
  818. * @return name:title type:string default:-- desc:标题
  819. * @return name:video_id type:string default:-- desc:视频id
  820. * @return name:url_id type:string default:-- desc:url_id
  821. * @return name:cover type:string default:-- desc:封面
  822. * @return name:time type:string default:-- desc:时间
  823. * @return name:ali_vid type:string default:-- desc:云点播id
  824. * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
  825. */
  826. public function getLearnHistory()
  827. {
  828. $sel_where = [];
  829. $sel_where[] = ['t.user_id','=',$this->user_id];
  830. $sel_where[] = ['t.type','=',1];
  831. $title = input('get.title');
  832. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  833. $list = UserTrack::where($sel_where)
  834. ->alias('t')
  835. ->field('t.id,t.update_int,t.first_id video_id,t.second_id url_id,i.title,i.cover,i.ali_vid')
  836. ->leftJoin('VideoUrl i','t.second_id = i.id')
  837. ->order('update_int desc')
  838. ->limit($this->off_set,$this->page_num)
  839. ->select()->toArray();
  840. foreach ($list as &$v) {
  841. $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
  842. }
  843. $this->success('ok',['list'=>$list]);
  844. }
  845. /**
  846. * @title 回复我的【回复我的--回复过我的评论】
  847. * @desc 回复我的
  848. * @author qc
  849. * @method GET
  850. * @url /api/Video/getReplayComment
  851. * @header name:Authorization require:1 desc:Token
  852. * @param name:title type:string default:-- desc:标题
  853. * @param name:page type:int default:0 desc:页数
  854. * @param name:page_num type:int default:20 desc:每页数
  855. * @return name:title type:string default:-- desc:标题
  856. * @return name:video_id type:string default:-- desc:视频id
  857. * @return name:url_id type:string default:-- desc:url_id
  858. * @return name:cover type:string default:-- desc:封面
  859. * @return name:create_at type:string default:-- desc:时间
  860. * @return name:user_name type:string default:-- desc:用户名【其他会员】
  861. * @return name:headimg type:string default:-- desc:用户头【其他会员】
  862. * @return name:parent_comment type:array default:-- desc:你的评论内容【别人回复的那个评论】
  863. * @return name:parent_comment.content type:string default:-- desc:内容
  864. * @return name:parent_comment.name type:string default:-- desc:会员名称
  865. * @return name:parent_comment.title type:string default:-- desc:视频标题
  866. * @return name:parent_comment.video_id type:string default:-- desc:视频id
  867. * @return name:parent_comment.url_id type:string default:-- desc:url_id
  868. * @return name:parent_comment.ali_vid:string default:-- desc:云点播id
  869. */
  870. public function getReplayComment()
  871. {
  872. $all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  873. if(empty($all_comment)) $this->success('ok',['list'=>null]);
  874. $sel_where = [];
  875. $title = input('get.title');
  876. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  877. $sel_where[] = ['t.is_deleted','=',0];
  878. $sel_where[] = ['t.lev','=',2];
  879. $sel_where[] = ['t.user_id','<>',$this->user_id];
  880. $sel_where[] = ['t.pid','in',implode(',',$all_comment)];
  881. $list = VideoComment::where($sel_where)
  882. ->alias('t')
  883. ->field('t.id,t.create_at,t.lev,t.content,t.pid,u.name user_name,u.headimg,i.id url_id,i.video_id,i.ali_vid,i.cover')
  884. ->leftJoin('store_member u','t.user_id = u.id')
  885. ->leftJoin('VideoUrl i','t.url_id = i.id')
  886. ->order('t.id desc')
  887. ->limit($this->off_set,$this->page_num)
  888. ->select()->toArray();
  889. foreach ($list as &$v) {
  890. $parent_comment = VideoComment::where([['t.id','=',$v['pid']]])
  891. ->field('t.id,t.video_id,t.url_id,t.content,i.title,i.cover,t.pid,u.name,i.ali_vid')
  892. ->alias('t')
  893. ->leftJoin('VideoUrl i','t.url_id = i.id')
  894. ->leftJoin('store_member u','t.user_id = u.id')
  895. ->find()->toArray();
  896. $v['parent_comment'] = $parent_comment;
  897. }
  898. $this->success('ok',['list'=>$list]);
  899. }
  900. /**
  901. * @title 我的回复【我的回复--我回复过的评论】
  902. * @desc 我的评论
  903. * @author qc
  904. * @method GET
  905. * @url /api/Video/getReplyVideo
  906. * @header name:Authorization require:1 desc:Token
  907. * @param name:title type:string default:-- desc:标题
  908. * @param name:page type:int default:0 desc:页数
  909. * @param name:page_num type:int default:20 desc:每页数
  910. * @return name:title type:string default:-- desc:标题
  911. * @return name:video_id type:string default:-- desc:视频id
  912. * @return name:url_id type:string default:-- desc:url_id
  913. * @return name:cover type:string default:-- desc:封面
  914. * @return name:create_at type:string default:-- desc:时间
  915. * @return name:user_name type:string default:-- desc:用户名【用户自己的】
  916. * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
  917. * @return name:parent_comment type:array default:-- desc:上级评论内容【你评论的那个评论】
  918. * @return name:parent_comment.content type:string default:-- desc:内容
  919. * @return name:parent_comment.name type:string default:-- desc:会员名称
  920. * @return name:parent_comment.title type:string default:-- desc:视频标题
  921. * @return name:parent_comment.video_id type:string default:-- desc:视频id
  922. * @return name:parent_comment.url_id type:string default:-- desc:url_id
  923. * @return name:parent_comment.ali_vid:string default:-- desc:云点播id
  924. */
  925. public function getReplyVideo()
  926. {
  927. $user_info = $this->userInfo();
  928. $sel_where = [];
  929. $title = input('get.title');
  930. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  931. $sel_where[] = ['t.user_id','=',$this->user_id];
  932. $sel_where[] = ['t.is_deleted','=',0];
  933. $sel_where[] = ['t.lev','=',2];
  934. $list = VideoComment::where($sel_where)
  935. ->alias('t')
  936. ->field('t.id,t.create_at,t.lev,t.content,i.title,t.pid,i.id url_id,i.video_id,i.ali_vid,i.cover')
  937. ->leftJoin('VideoUrl i','t.url_id = i.id')
  938. ->order('t.id desc')
  939. ->limit($this->off_set,$this->page_num)
  940. ->select()->toArray();
  941. foreach ($list as &$v) {
  942. $v['user_name'] = $user_info['name'];
  943. $v['headimg'] = $user_info['headimg'];
  944. $parent_comment = VideoComment::where([['t.id','=',$v['pid']]])
  945. ->field('t.id,t.video_id,t.url_id,t.content,i.title,i.cover,t.pid,u.name,i.ali_vid')
  946. ->alias('t')
  947. ->leftJoin('VideoUrl i','t.url_id = i.id')
  948. ->leftJoin('store_member u','t.user_id = u.id')
  949. ->find()->toArray();
  950. $v['parent_comment'] = $parent_comment;
  951. }
  952. $this->success('ok',['list'=>$list]);
  953. }
  954. /**
  955. * @title 我的评论【学习服务--我评论过的视频】
  956. * @desc 我的评论
  957. * @author qc
  958. * @method GET
  959. * @url /api/Video/getCommentVideo
  960. * @header name:Authorization require:1 desc:Token
  961. * @param name:title type:string default:-- desc:标题
  962. * @param name:page type:int default:0 desc:页数
  963. * @param name:page_num type:int default:20 desc:每页数
  964. * @return name:title type:string default:-- desc:标题
  965. * @return name:video_id type:string default:-- desc:视频id
  966. * @return name:url_id type:string default:-- desc:url_id
  967. * @return name:cover type:string default:-- desc:封面
  968. * @return name:create_at type:string default:-- desc:时间
  969. * @return name:user_name type:string default:-- desc:用户名【用户自己的】
  970. * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
  971. * @return name:ali_vid:string default:-- desc:云点播id
  972. */
  973. public function getCommentVideo()
  974. {
  975. $user_info = $this->userInfo();
  976. $sel_where = [];
  977. $title = input('get.title');
  978. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  979. $sel_where[] = ['t.user_id','=',$this->user_id];
  980. $sel_where[] = ['t.is_deleted','=',0];
  981. $list = VideoComment::where($sel_where)
  982. ->alias('t')
  983. ->field('t.id,t.create_at,t.video_id,t.url_id,t.lev,t.content,i.title,i.cover,i.ali_vid,i.cover')
  984. ->leftJoin('VideoUrl i','t.url_id = i.id')
  985. ->order('id desc')
  986. ->limit($this->off_set,$this->page_num)
  987. ->select()->toArray();
  988. foreach ($list as &$v)
  989. {
  990. $v['user_name'] = $user_info['name'];
  991. $v['headimg'] = $user_info['headimg'];
  992. }
  993. $this->success('ok',['list'=>$list]);
  994. }
  995. /**
  996. * @title 评论我的【学习服务--评论我的】
  997. * @desc 评论我的
  998. * @author qc
  999. * @method GET
  1000. * @url /api/Video/commentMyVideo
  1001. * @header name:Authorization require:1 desc:Token
  1002. * @param name:title type:string default:-- desc:标题
  1003. * @param name:page type:int default:0 desc:页数
  1004. * @param name:page_num type:int default:20 desc:每页数
  1005. * @return name:title type:string default:-- desc:标题
  1006. * @return name:video_id type:string default:-- desc:视频id
  1007. * @return name:url_id type:string default:-- desc:url_id
  1008. * @return name:cover type:string default:-- desc:封面
  1009. * @return name:create_at type:string default:-- desc:时间
  1010. * @return name:user_name type:string default:-- desc:用户名
  1011. * @return name:headimg type:string default:-- desc:用户头像
  1012. * @return name:ali_vid:string default:-- desc:云点播id
  1013. */
  1014. public function commentMyVideo()
  1015. {
  1016. $sel_where = [];
  1017. $title = input('get.title');
  1018. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1019. $sel_where[] = ['t.is_deleted','=',0];
  1020. $sel_where[] = ['i.user_id','=',$this->user_id];
  1021. $list = VideoComment::where($sel_where)
  1022. ->alias('t')
  1023. ->field('t.id,t.create_at,t.video_id,t.video_id,t.lev,t.content,i.title,i.cover,i.ali_vid,u.name user_name,u.headimg')
  1024. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1025. ->leftJoin('store_member u','t.user_id = u.id')
  1026. ->order('t.id desc')
  1027. ->limit($this->off_set,$this->page_num)
  1028. ->select()->toArray();
  1029. $this->success('ok',['list'=>$list]);
  1030. }
  1031. /**
  1032. * @title 已购视频列表
  1033. * @desc 已购视频列表
  1034. * @author qc
  1035. * @method GET
  1036. * @url /api/Video/getPurchaseVideo
  1037. * @header name:Authorization require:1 desc:Token
  1038. * @param name:title type:string default:-- desc:标题
  1039. * @param name:page type:int default:0 desc:页数
  1040. * @param name:page_num type:int default:20 desc:每页数
  1041. * @return name:title type:string default:-- desc:标题
  1042. * @return name:video_id type:string default:-- desc:视频id
  1043. * @return name:url_id type:string default:-- desc:url_id
  1044. * @return name:cover type:string default:-- desc:封面
  1045. * @return name:create_at type:string default:-- desc:时间
  1046. * @return name:ali_vid type:string default:-- desc:云点播id
  1047. * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
  1048. */
  1049. public function getPurchaseVideo()
  1050. {
  1051. $sel_where = [];
  1052. $title = input('get.title');
  1053. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1054. $sel_where[] = ['t.user_id','=',$this->user_id];
  1055. $sel_where[] = ['t.type','=',1];
  1056. $sel_where[] = ['t.end_int','>',time()];
  1057. $list = UserLearn::where($sel_where)
  1058. ->alias('t')
  1059. ->field('t.id,t.create_at,t.first_id video_id,t.second_id url_id,i.title,i.cover,i.is_vip,i.ali_vid')
  1060. ->leftJoin('VideoUrl i','t.second_id = i.id')
  1061. ->order('id desc')
  1062. ->limit($this->off_set,$this->page_num)
  1063. ->select()->toArray();
  1064. $this->success('ok',['list'=>$list]);
  1065. }
  1066. /**
  1067. * @title 视频收藏记录【我的收藏】
  1068. * @desc 视频收藏记录
  1069. * @author qc
  1070. * @method GET
  1071. * @url /api/Video/getVideoCollect
  1072. * @header name:Authorization require:1 desc:Token
  1073. * @param name:title type:string default:-- desc:标题
  1074. * @param name:page type:int default:0 desc:页数
  1075. * @param name:page_num type:int default:20 desc:每页数
  1076. * @return name:title type:string default:-- desc:标题
  1077. * @return name:video_id type:string default:-- desc:视频id
  1078. * @return name:url_id type:string default:-- desc:url_id
  1079. * @return name:cover type:string default:-- desc:封面
  1080. * @return name:create_at type:string default:-- desc:时间
  1081. * @return name:ali_vid type:string default:-- desc:云点播id
  1082. * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
  1083. */
  1084. public function getVideoCollect()
  1085. {
  1086. $sel_where = [];
  1087. $title = input('get.title');
  1088. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1089. $sel_where[] = ['t.user_id','=',$this->user_id];
  1090. $sel_where[] = ['t.coll_type','=',1];
  1091. $list = UserCollect::where($sel_where)
  1092. ->alias('t')
  1093. ->field('t.id,t.create_at,t.coll_id video_id,t.children_id url_id,i.title,i.cover,i.is_vip,i.ali_vid')
  1094. ->leftJoin('VideoUrl i','t.children_id = i.id')
  1095. ->order('id desc')
  1096. ->limit($this->off_set,$this->page_num)
  1097. ->select()->toArray();
  1098. $this->success('ok',['list'=>$list]);
  1099. }
  1100. /**
  1101. * @title 视频点赞列表【我的点赞】
  1102. * @desc 视频点赞列表
  1103. * @author qc
  1104. * @method GET
  1105. * @url /api/Video/getTagsVideo
  1106. * @header name:Authorization require:1 desc:Token
  1107. * @param name:title type:string default:-- desc:标题
  1108. * @param name:page type:int default:0 desc:页数
  1109. * @param name:page_num type:int default:20 desc:每页数
  1110. * @return name:title type:string default:-- desc:标题
  1111. * @return name:video_id type:string default:-- desc:视频id
  1112. * @return name:url_id type:string default:-- desc:url_id
  1113. * @return name:cover type:string default:-- desc:封面
  1114. * @return name:create_at type:string default:-- desc:时间
  1115. * @return name:ali_vid type:string default:-- desc:云点播id
  1116. * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
  1117. */
  1118. public function getTagsVideo()
  1119. {
  1120. $sel_where = [];
  1121. $title = input('get.title');
  1122. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1123. $sel_where[] = ['t.user_id','=',$this->user_id];
  1124. $sel_where[] = ['t.type','=',2];
  1125. $list = VideoCommentLike::where($sel_where)
  1126. ->alias('t')
  1127. ->field('t.id,t.create_at,t.like_id url_id,i.title,i.cover,i.is_vip,i.cover,i.ali_vid,i.video_id')
  1128. ->leftJoin('VideoUrl i','t.like_id = i.id')
  1129. ->order('id desc')
  1130. ->limit($this->off_set,$this->page_num)
  1131. ->select()->toArray();
  1132. $this->success('ok',['list'=>$list]);
  1133. }
  1134. }