token['root_org']]; $condition[] = ['publish','=',1]; $condition[] = ['delete_time','=',0]; empty($label) ?: $condition[] = ['label', '=', $label]; empty($type) ?: $condition[] = ['type', '=', $type]; empty($keyword) ?: $condition[] = ['title', 'like', '%' . $keyword . '%']; // 获取数据 $data = VideoModel::where($condition)->field('id,title,description,video_url,cover')->page($page , $limit)->order('uploadtime desc')->select()->toArray(); $count = VideoModel::where($condition)->count(); return json(['code' => 0, 'data' => $data, 'count' => $count, 'msg' => '获取成功']); } /** * 类型获取 */ public function type() { $type = VideoType::where(['pid'=>0 , 'type'=>'video', 'root_id' => request()->token['root_org']])->select()->toArray(); $label = VideoType::where([['pid','>',0] , ['type','=','video'],['root_id','=',request()->token['root_org']]])->select()->toArray(); foreach($type as &$val) { $val['sonLabel'] = []; foreach($label as $typeVal) { if($val['id'] == $typeVal['pid']) { $val['sonLabel'][] = $typeVal; } } } return json(['code' => 0, 'data' => $type, 'msg' => '获取成功']); } /** * 获取视频详情 */ public function info($video_id) { $video = VideoModel::where(['id'=>$video_id , 'publish'=>1 , 'delete_time'=>0])->find(); // 添加足迹 $token = request()->token; if (!empty($token['uid']) && !$token['isEmployee']) { event(new FootPrints($token['uid'], $token['share_employee'] ?? 0, $token['share_org'] ?? 0, $video)); } if (!$token['isEmployee']) { VideoModel::where('id', '=', $video_id)->inc('view_times')->update(); } return json(['code' => 0, 'msg' => '获取成功', 'data' => $video]); } }