Video.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 视频
  7. */
  8. class Video extends Api
  9. {
  10. // 无需登录的接口,*表示全部
  11. protected $noNeedLogin = [];
  12. // 无需鉴权的接口,*表示全部
  13. protected $noNeedRight = ['*'];
  14. public function lists(){
  15. $week = input('week',1);
  16. if($week == 1){
  17. $starttime = strtotime(date('Y-m-d')) - 86400*7;
  18. }else{
  19. $starttime = strtotime(date('Y-m-d')) - 86400*14;
  20. }
  21. $list = Db::name('video')->where('createtime','>',$starttime)->where('is_show',1)->order('weigh desc')->autopage()->select();
  22. $list = list_domain_image($list,['video_file']);
  23. if(!empty($list)){
  24. foreach($list as $key => &$val){
  25. if(!empty($val['video_file'])){
  26. $val['thumb_image'] = $val['video_file'].'?x-oss-process=video/snapshot,t_100,f_png,m_fast';
  27. }
  28. $val['createtime'] = date('Y-m-d H:i:s',$val['createtime']);
  29. }
  30. }
  31. $this->success(1,$list);
  32. }
  33. public function info(){
  34. $id = input('id');
  35. $info = Db::name('video')->where('id',$id)->find();
  36. $info = info_domain_image($info,['video_file']);
  37. if(!empty($info)){
  38. if(!empty($info['video_file'])){
  39. $info['thumb_image'] = $info['video_file'].'?x-oss-process=video/snapshot,t_100,f_png,m_fast';
  40. }
  41. $info['createtime'] = date('Y-m-d H:i:s',$info['createtime']);
  42. }
  43. $this->success(1,$info);
  44. }
  45. }