title = '视频列表'; $this->video_id = input('video_id'); $sel_where = []; $sel_where[] = ['is_deleted','=',0]; $sel_where[] = ['video_id','=',$this->video_id]; $query = $this->_query($this->table); $query->where($sel_where)->order('sort desc,id asc')->page(false); } /** * 数据列表处理 * @auth true * @menu true * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _index_page_filter(&$data) { } /** * 添加 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function add() { $this->title = '添加视频'; $this->_form($this->table, 'form'); } /** * 编辑 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function edit() { $this->title = '编辑视频'; $this->_form($this->table, 'form') ; } /** * 删除视频 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function del() { $video_id = \app\common\model\VideoUrl::where('id',input('id'))->value('video_id'); VideoIntro::where('id',$video_id)->setDec('url_num'); $this->_save($this->table, ['is_deleted' => 1]); } /** * 表单数据处理 * @auth true * @menu true * @param array $data */ protected function _form_filter(&$data) { if($this->request->isGet()){ $this->video_id = input('video_id'); $this->video_info = VideoIntro::where('id',$this->video_id)->find()->toArray(); if($this->request->action() == 'add')$data['is_vip'] = $this->video_info['is_vip']; // 文章列表 $this->article_list =\app\common\model\ArticleIntro::with('itemChildren') ->field('id,title') ->where(['is_deleted'=>0])->order('id asc') ->select()->toArray(); // 资料 /* $this->datum_list = DatumIntro::with('urlArr') ->where(['is_deleted'=>0])->order('id desc') ->select()->toArray();*/ $this->datum_list = []; } if($this->request->isPost()){ list($post) = [$this->request->post()]; if(empty($data['cover'])) $this->error('请上传视频封面'); if(empty($data['ali_vid'])) $this->error('云点播ID不能为空'); $vid_info = getVideoTime($data['ali_vid']); $data['duration'] = $vid_info['duration']; $data['duration_str'] = $vid_info['duration_str']; if(!empty($post['phone'])) { $user_id = User::where('phone|email',$post['phone'])->value('id'); if(!$user_id) $this->error('账号未注册'); $data['user_id'] = $user_id; }else{ $data['user_id'] = ''; } } } protected function _form_result($result) { $url_num = \app\common\model\VideoUrl::field('id,read_num')->where(['video_id'=>$this->request->post('video_id'),'is_deleted'=>0])->select()->toArray(); $video_info = VideoIntro::where('id',$this->request->post('video_id'))->find()->toArray(); $url = $this->request->post('up_type',1) == 1 ? $this->request->post('up_url'):$this->request->post('path'); $up['url_num'] = count($url_num); $up['read_num'] = array_sum(array_column($url_num,'read_num')); if(!$video_info['cover']) $up['cover'] = $this->request->post('cover'); if(!$video_info['video_url']) $up['video_url'] = $url; if(!$video_info['article_id']) $up['article_id'] = $this->request->post('article_id'); if(!$video_info['article_item']) $up['article_item'] = $this->request->post('article_item'); if(!$video_info['datum_id']) $up['datum_id'] = $this->request->post('datum_id'); if(!$video_info['datum_item']) $up['datum_item'] = $this->request->post('datum_item'); VideoIntro::where('id',$this->request->post('video_id'))->update($up); $this->success('操作成功', 'javascript:history.back()'); } /** * 禁用 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function forbidden() { $this->_save($this->table, ['status' => '0']); } /** * 启用 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function enable() { $this->_save($this->table, ['status' => 1]); } }