1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 视频
- */
- class Video extends Api
- {
- // 无需登录的接口,*表示全部
- protected $noNeedLogin = [];
- // 无需鉴权的接口,*表示全部
- protected $noNeedRight = ['*'];
- public function lists(){
- $week = input('week',1);
- if($week == 1){
- $starttime = strtotime(date('Y-m-d')) - 86400*7;
- }else{
- $starttime = strtotime(date('Y-m-d')) - 86400*14;
- }
- $list = Db::name('video')->where('createtime','>',$starttime)->where('is_show',1)->order('weigh desc')->autopage()->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'] = date('Y-m-d H:i:s',$val['createtime']);
- }
- }
- $this->success(1,$list);
- }
- public function info(){
- $id = input('id');
- $info = Db::name('video')->where('id',$id)->find();
- $info = info_domain_image($info,['video_file']);
- if(!empty($info)){
- if(!empty($info['video_file'])){
- $info['thumb_image'] = $info['video_file'].'?x-oss-process=video/snapshot,t_100,f_png,m_fast';
- }
- $info['createtime'] = date('Y-m-d H:i:s',$info['createtime']);
- }
- $this->success(1,$info);
- }
- }
|