lizhen_gitee 1 vuosi sitten
vanhempi
commit
1c726c6bc3

+ 40 - 0
application/api/controller/Video.php

@@ -0,0 +1,40 @@
+<?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)->autopage()->select();
+        $list = list_domain_image($list,['video_file']);
+
+        $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']);
+
+        $this->success(1,$info);
+    }
+}

+ 47 - 0
application/api/controller/coach/Video.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace app\api\controller\coach;
+
+use app\common\controller\Apic;
+use think\Db;
+/**
+ * 视频
+ */
+class Video extends Apic
+{
+    // 无需登录的接口,*表示全部
+    protected $noNeedLogin = [];
+    // 无需鉴权的接口,*表示全部
+    protected $noNeedRight = ['*'];
+
+    public function lists(){
+
+        $list = Db::name('video')->where('coach_id',$this->auth->id)->autopage()->order('id desc')->select();
+        $list = list_domain_image($list,['video_file']);
+
+        $this->success(1,$list);
+    }
+
+    public function addone(){
+        $name = input('name','');
+        $video_file = input('video_file','');
+
+        if(!$name || !$video_file){
+            $this->error('标题和视频必填');
+        }
+
+        $data = [
+            'name' => $name,
+            'video_file' => $video_file,
+            'createtime' => time(),
+            'coach_id' => $this->auth->id,
+            //获取视频大小和秒数
+        ];
+
+        $id = Db::name('video')->insertGetId($data);
+
+        $this->success('发布成功',$id);
+    }
+
+
+}

+ 2 - 2
application/common/controller/Api.php

@@ -129,12 +129,12 @@ class Api
                 $this->error(__('Please login first'), null, 401);
             }
             // 判断是否需要验证权限
-            if (!$this->auth->match($this->noNeedRight)) {
+            /*if (!$this->auth->match($this->noNeedRight)) {
                 // 判断控制器和方法判断是否有对应权限
                 if (!$this->auth->check($path)) {
                     $this->error(__('You have no permission'), null, 403);
                 }
-            }
+            }*/
         } else {
             // 如果有传递token才验证是否登录状态
             if ($token) {

+ 2 - 2
application/common/controller/Apic.php

@@ -126,12 +126,12 @@ class Apic
                 $this->error(__('Please login first'), null, 401);
             }
             // 判断是否需要验证权限
-            if (!$this->auth->match($this->noNeedRight)) {
+            /*if (!$this->auth->match($this->noNeedRight)) {
                 // 判断控制器和方法判断是否有对应权限
                 if (!$this->auth->check($path)) {
                     $this->error(__('You have no permission'), null, 403);
                 }
-            }
+            }*/
         } else {
             // 如果有传递token才验证是否登录状态
             if ($token) {