Vdlist.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\Home\controller;
  3. use think\Db;
  4. class Vdlist extends Base
  5. {
  6. // public $post="";
  7. // public $userinfo="";
  8. public function __construct()
  9. {
  10. parent:: __construct();
  11. // $post=request()->post();
  12. // $this->post=$post;
  13. }
  14. public function obtainlist(){
  15. $page = isset($this->post['page'])&&$this->post['page']!="" ? intval($this->post['page']):1;
  16. $size = isset($this->post['size'])&&$this->post['size']!="" ? intval($this->post['size']):10;
  17. $where = ["b.is_del"=>0,'a.accountid'=>$this->userinfo['id'],"a.is_del"=>0,"b.status"=>1,"a.status"=>1];
  18. $count = Db::name("rela_video")->alias('a')->join("video b","a.video_id=b.id","left")->where($where)->count();
  19. //var_dump(Db::name("rela_video")->getLastSql());
  20. $total = ceil($count/$size);
  21. $page = $page>$total?$total:$page;
  22. //var_dump(Db::name("rela_video")->getLastSql());
  23. $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();
  24. return app_show(0,"视频列表获取成功",["list"=>$list,"count"=>$count]);
  25. }
  26. public function preview(){
  27. $id = isset($this->post['id'])&&$this->post['id']!="" ? intval($this->post['id']):"";
  28. $where = ['b.id'=>$id,'a.accountid'=>$this->userinfo['id'],'b.is_del'=>0,'b.status'=>1,'a.is_del'=>0,'a.status'=>1];
  29. $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();
  30. // var_dump(Db::name("rela_video")->getLastSql());
  31. if($look==false){
  32. return error_show(1002,"预览失败");
  33. }else
  34. return app_show(0,"预览成功",$look);
  35. }
  36. }