1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\api\controller\coach;
- use app\common\controller\Apic;
- use think\Db;
- /**
- * 视频
- */
- class Video extends Apic
- {
- // 无需登录的接口,*表示全部
- protected $noNeedLogin = [];
- // 无需鉴权的接口,*表示全部
- protected $noNeedRight = ['*'];
- public function lists(){
- $list = Db::name('video')->where('coach_id',$this->auth->id)->autopage()->order('id desc')->select();
- $list = list_domain_image($list,['video_file']);
- if(!empty($list)){
- foreach($list as $key => &$val){
- if(!empty($val['video_file'])){
- $val['thumb_image'] = $val['video_file'].'?x-oss-process=video/snapshot,t_100,f_png,m_fast';
- }
- $val['createtime'] = $this->datetime_lang($val['createtime']);
- }
- }
- $this->success(1,$list);
- }
- public function addone(){
- $name = input('name','');
- $video_file = input('video_file','');
- $size = input('size','');
- $second = input('second',0,'intval');
- if(!$name || !$video_file){
- $this->error('标题和视频必填');
- }
- $data = [
- 'name' => $name,
- 'video_file' => $video_file,
- 'createtime' => time(),
- 'coach_id' => $this->auth->id,
- //获取视频大小和秒数
- 'size' => $size,
- 'second' => $second,
- ];
- $id = Db::name('video')->insertGetId($data);
- $this->success('发布成功',$id);
- }
- }
|