1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\Home\controller;
- use think\Db;
- class Vdlist extends Base
- {
- // public $post="";
- // public $userinfo="";
- public function __construct()
- {
- parent:: __construct();
- // $post=request()->post();
- // $this->post=$post;
- }
- public function obtainlist(){
- $page = isset($this->post['page'])&&$this->post['page']!="" ? intval($this->post['page']):1;
- $size = isset($this->post['size'])&&$this->post['size']!="" ? intval($this->post['size']):10;
- $where = ["b.is_del"=>0,'a.accountid'=>$this->userinfo['id'],"a.is_del"=>0,"b.status"=>1,"a.status"=>1];
- $count = Db::name("rela_video")->alias('a')->join("video b","a.video_id=b.id","left")->where($where)->count();
- //var_dump(Db::name("rela_video")->getLastSql());
- $total = ceil($count/$size);
- $page = $page>$total?$total:$page;
- //var_dump(Db::name("rela_video")->getLastSql());
- $list = Db::name("rela_video")->alias('a')->join("video b","a.video_id=b.id","left")->where($where)->page($page,$size)->field("b.id,b.video_sn,b.video_name,b.video_url,b.video_img,b.remark")->select();
- return app_show(0,"视频列表获取成功",["list"=>$list,"count"=>$count]);
- }
- public function preview(){
- $id = isset($this->post['id'])&&$this->post['id']!="" ? intval($this->post['id']):"";
- $where = ['b.id'=>$id,'a.accountid'=>$this->userinfo['id'],'b.is_del'=>0,'b.status'=>1,'a.is_del'=>0,'a.status'=>1];
- $look = Db::name("rela_video")->alias('a')->join("video b","a.video_id=b.id","left")->where($where)->field("b.id,b.video_sn,b.video_name,b.video_url,b.video_img,b.remark")->find();
- // var_dump(Db::name("rela_video")->getLastSql());
- if($look==false){
- return error_show(1002,"预览失败");
- }else
- return app_show(0,"预览成功",$look);
- }
- }
|