12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Gold
- * Date: 2024/1/15
- * Time: 17:45
- */
- namespace app\api\controller;
- use app\admin\model\books\Certificate;
- use app\admin\model\order\UserGoods;
- use app\admin\model\video\Video as VideoModel; //视频
- use app\admin\model\video\VideoFile; //视频
- use app\common\controller\Api;
- class Video extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- /**
- * 视频列表
- *
- * api/video/getVideoList
- */
- public function getVideoList(){
- $data = input();
- $where = [];
- if(!isset($data['page']) || $data['page'] == '' || $data['page'] == null){
- $page = 1;
- }else{
- $page = $data['page'];
- }
- if(!isset($data['limit']) || $data['limit'] == '' || $data['limit'] == null){
- $limit = 20;
- }else{
- $limit = $data['limit'];
- }
- if ( isset($data['keywords']) && $data['keywords'] != '' && $data['keywords'] != null){
- $where['title'] = ['like','%'.$data['keywords'].'%'];
- }
- $VideoModel = new VideoModel();
- $list = $VideoModel->where('is_deleted',1)->where($where)->order('sort desc,id desc')->paginate([
- 'list_rows'=> $limit,
- 'page' => $page,
- ]);
- $this->success('操作成功',$list);
- }
- /**
- * 视频详情
- *
- * api/video/getVideoInfo
- */
- public function getVideoInfo(){
- $data = input();
- if(!isset($data['id']) || !$data['id']){
- $this->error('参数错误');
- }
- $VideoModel = new VideoModel();
- $id = $data['id'];
- $list = $VideoModel->where('id',$id)->where('is_deleted',1)->with(['file'])->find();
- $list['is_pay'] = 1;
- //判断是否已购买
- if($this->auth->isLogin()){
- $UserGoods = new UserGoods();
- $uid = $this->auth->id;
- $good = $UserGoods->where('user_id',$uid)->where('goods_type',1)->where('goods_id',$id)->find();
- if($good){
- $list['is_pay'] = 0;
- }
- }
- if(!$list){
- $this->error('教材不存在或已删除');
- }
- $this->success('操作成功',$list);
- }
- }
|