Video.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\api\controller\coach;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 视频
  7. */
  8. class Video extends Apic
  9. {
  10. // 无需登录的接口,*表示全部
  11. protected $noNeedLogin = [];
  12. // 无需鉴权的接口,*表示全部
  13. protected $noNeedRight = ['*'];
  14. public function lists(){
  15. $list = Db::name('video')->where('coach_id',$this->auth->id)->autopage()->order('id desc')->select();
  16. $list = list_domain_image($list,['video_file']);
  17. $this->success(1,$list);
  18. }
  19. public function addone(){
  20. $name = input('name','');
  21. $video_file = input('video_file','');
  22. if(!$name || !$video_file){
  23. $this->error('标题和视频必填');
  24. }
  25. $data = [
  26. 'name' => $name,
  27. 'video_file' => $video_file,
  28. 'createtime' => time(),
  29. 'coach_id' => $this->auth->id,
  30. //获取视频大小和秒数
  31. ];
  32. $id = Db::name('video')->insertGetId($data);
  33. $this->success('发布成功',$id);
  34. }
  35. }