浏览代码

视频库基本管理

liuzejian 2 年之前
父节点
当前提交
5c7595d09d

+ 70 - 0
modules/Video/Http/Controllers/EpisodeController.php

@@ -0,0 +1,70 @@
+<?php
+
+namespace Modules\Video\Http\Controllers;
+
+use Catch\Base\CatchController;
+use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Modules\Common\Errors\Errors;
+use Modules\Common\Exceptions\CommonBusinessException;
+use Modules\User\Models\User;
+use Modules\Video\Services\VideoService;
+
+class EpisodeController extends CatchController
+{
+    use UserTrait;
+    use ValidatesRequests;
+
+    public function list(Request $request) {
+        $this->validate($request, [
+            'video_id' => 'required'
+        ]);
+
+        $video = VideoService::getVideoByIdOrException($request->input('video_id'));
+
+        VideoService::updateVideoChargeInfo($video, $this->getUserContext($request->input('operateUserId')));
+
+        $videoSeries = DB::table('video_series')
+            ->where([
+                'video_id' => $request->integer('video_id'),
+                'is_enabled' => 1
+            ])->select('series_name', 'series_sequence', 'video_url', 'duration')
+            ->orderBy('series_sequence', 'asc')
+            ->paginate($request->integer('per_page', 15));
+        foreach ($videoSeries as $series) {
+            $series->series_name = sprintf('第%s集', $series->series_sequence);
+            $series->is_charge = $series->series_sequence >= $video->charge_sequence;
+            $series->duration_str = gmdate('H:i:s', $series->duration);
+        }
+
+        return $videoSeries;
+    }
+
+    public function add(Request $request) {
+        $this->validate($request, [
+            'video_id' => 'required',
+            'videos' => 'required|array|min:1',
+            'videos.*.url' => 'required',
+            'videos.*.name' => 'required',
+            'videos.*.duration' => 'required|integer|min:1'
+        ]);
+        VideoService::getVideoByIdOrException($request->input('video_id'));
+        $videos = $request->input('videos');
+        $data = [];
+        $now = date('Y-m-d H:i:s');
+        foreach ($videos as $item) {
+            $data[] = [
+                'video_id' => $request->input('video_id'),
+                'video_url' => $item['url'],
+                'series_name' => $item['name'],
+                'series_sequence' => intval(explode('_', $item['name'])[0]),
+                'duration' => $item['duration'],
+                'created_at' => $now,
+                'updated_at' => $now,
+            ];
+        }
+        DB::table('video_series')->insert($data);
+        return 1;
+    }
+}

+ 23 - 0
modules/Video/Http/Controllers/UserTrait.php

@@ -3,8 +3,11 @@
 namespace Modules\Video\Http\Controllers;
 
 use Catch\Base\CatchController;
+use Illuminate\Http\Request;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\DB;
+use Modules\Common\Errors\Errors;
+use Modules\Common\Exceptions\CommonBusinessException;
 use Modules\User\Models\User;
 
 trait UserTrait
@@ -55,4 +58,24 @@ trait UserTrait
         }
     }
 
+    protected function getUserContext($operateUserId) {
+        $loginUser = $this->getLoginUser();
+        $loginUserRoles = $this->listUserRoles();
+        if($operateUserId) {
+            $operateUser = User::find($operateUserId);
+            $operateUserRoles = $operateUser->roles->pluck('identify');
+            if($loginUser->id != $operateUser->pid) {
+                CommonBusinessException::throwError(Errors::NO_OPERATE_PERMISSION);
+            }
+            if(!$operateUserRoles->contains('optimizer')) {
+                CommonBusinessException::throwError(Errors::NO_OPERATE_PERMISSION);
+            }
+        } else {
+            $operateUser = $loginUser;
+            $operateUserRoles = $loginUserRoles;
+        }
+
+        return compact('loginUser', 'loginUserRoles', 'operateUserRoles', 'operateUser');
+    }
+
 }

+ 12 - 54
modules/Video/Http/Controllers/VideoController.php

@@ -9,6 +9,7 @@ use Illuminate\Support\Facades\DB;
 use Modules\Common\Errors\Errors;
 use Modules\Common\Exceptions\CommonBusinessException;
 use Modules\User\Models\User;
+use Modules\Video\Services\VideoService;
 
 class VideoController extends CatchController
 {
@@ -25,8 +26,12 @@ class VideoController extends CatchController
         $videoName = $request->input('videoName');
         $updateType = $request->input('updateType');
         $categoryId = $request->input('categoryId');
+        $videoId = $request->input('videoId');
 
         $videos = DB::table('videos')
+            ->when($videoId, function ($query, $videoId){
+                return $query->where('id', $videoId);
+            })
             ->when($videoName, function ($query, $videoName){
                return $query->where('name', 'like', '%'. $videoName . '%');
             })->when($updateType, function ($query, $updateType){
@@ -35,7 +40,7 @@ class VideoController extends CatchController
                 return $query->where('category_id', $categoryId);
             })->orderBy('id', 'desc')
             ->paginate($request->integer('per_page', 15));
-        $userContext = $this->getUserContext($request);
+        $userContext = $this->getUserContext($request->input('operateUserIdßßß'));
         $allVideoCategory =  DB::table('video_category')
             ->get()->keyBy('id');
         foreach ($videos as $video) {
@@ -58,12 +63,13 @@ class VideoController extends CatchController
             'chargeType' => 'required|integer|in:1',
             'chargeSequence' => 'required|integer|min:1|max:30'
         ]);
-        $userContext = $this->getUserContext($request);
-        if($userContext['loginUserRoles']->diff(['administrator', 'optimizer'])->isEmpty()) {
+        $userContext = $this->getUserContext($request->input('operateUserId'));
+        if(!(1 == $userContext['loginUser']->id ||
+            $userContext['loginUserRoles']->diff(['administrator', 'optimizer'])->isNotEmpty())) {
             CommonBusinessException::throwError(Errors::NO_OPERATE_PERMISSION);
         }
         $now = date('Y-m-d H:i:s');
-        if($userContext['loginUserRoles']->contains('administrator')) {
+        if($userContext['loginUserRoles']->contains('administrator') || 1 == $userContext['loginUser']->id) {
             DB::table('videos')
                 ->where('id', $request->input('id'))
                 ->update([
@@ -147,10 +153,7 @@ class VideoController extends CatchController
         $id = $request->input('id');
         $data = $request->except('id', 'shelf_at');
         $data['updated_at'] = date('Y-m-d H:i:s');
-        $video = DB::table('videos')->where('id', $id)->first();
-        if(!$video) {
-            CommonBusinessException::throwError(Errors::VIDEO_NOT_EXISTS);
-        }
+        $video = VideoService::getVideoByIdOrException($request->input('id'));
         if(2 == $request->integer('shelf_type') && 1 == $video->shelf_type) {
             $data['shelf_at'] = $data['updated_at'];
         }
@@ -161,57 +164,12 @@ class VideoController extends CatchController
     }
 
 
-    private function getUserContext(Request $request) {
-        $loginUser = $this->getLoginUser();
-        $loginUserRoles = $this->listUserRoles();
-        $operateUserId = $request->input('operateUserId');
-        if($operateUserId) {
-            $operateUser = User::find($operateUserId);
-            $operateUserRoles = $operateUser->roles->pluck('identify');
-            if($loginUser->id != $operateUser->pid) {
-                CommonBusinessException::throwError(Errors::NO_OPERATE_PERMISSION);
-            }
-            if(!$operateUserRoles->contains('optimizer')) {
-                CommonBusinessException::throwError(Errors::NO_OPERATE_PERMISSION);
-            }
-        } else {
-            $operateUser = $loginUser;
-            $operateUserRoles = $loginUserRoles;
-        }
 
-        return compact('loginUser', 'loginUserRoles', 'operateUserRoles', 'operateUser');
-    }
     private function updateVideoInfo($video, $userContext) {
-        if($userContext['loginUserRoles']->contains('administrator')) {
-            $video->charge_sequence = $video->d_charge_sequence;
-            $video->charge_coin = $video->d_charge_coin;
-            return;
-        }
-        if($userContext['loginUserRoles']->contains('company')) {
-            if($userContext['loginUser']->id == $userContext['operateUser']->id) {
-                $video->charge_sequence = $video->d_charge_sequence;
-                $video->charge_coin = $video->d_charge_coin;
-                return;
-            } else {
-                $videoUserConfig = $this->getVideoUserConfig($userContext['operateUser']->id, $video->id);
-                $video->charge_sequence = $videoUserConfig->charge_sequence ?? $video->d_charge_sequence;
-                $video->charge_coin = $videoUserConfig->charge_coin ?? $video->d_charge_coin;
-                return;
-            }
-        }
-        if($userContext['loginUserRoles']->contains('optimizer')) {
-            $videoUserConfig = $this->getVideoUserConfig($userContext['loginUser']->id, $video->id);
-            $video->charge_sequence = $videoUserConfig->charge_sequence ?? $video->d_charge_sequence;
-            $video->charge_coin = $videoUserConfig->charge_coin ?? $video->d_charge_coin;
-            return;
-        }
+        VideoService::updateVideoChargeInfo($video, $userContext);
     }
 
-    private function getVideoUserConfig($uid, $videoId) {
-         return DB::table('video_user_config')
-            ->where(['is_enabled' => 1, 'uid' => $uid, 'video_id' => $videoId])->first();
 
-    }
 
     private function getCategoryStr($allCategory,$categoryId) {
         $category = $allCategory->get($categoryId);

+ 0 - 88
modules/Video/Services/Notice/NoitceTypeService.php

@@ -1,88 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:NoitceTypeService.php
- * @Created by gnitif
- * @Date: 2023/3/27
- * @Time: 11:54
- */
-
-
-namespace Modules\System\Services\Notice;
-
-use Illuminate\Support\Facades\DB;
-use Modules\ContentManage\Models\NoticeTypes;
-
-class NoitceTypeService
-{
-
-    /**
-     *  添加分类
-     * name: store
-     * @param array $param
-     * $param [
-     *      'name' => "平台通知"
-     * ];
-     * date 2023/03/27 18:14
-     */
-    public static function store(array $param)
-    {
-        return self::getModel()->storeBy($param);
-    }
-
-    protected static function getModel(){
-         return new NoticeTypes();
-    }
-
-    /**
-     *  获取通知分类列表分类
-     * name: list
-     * @param mixed $param
-     *  $param = [
-     *      'name' => '系统通知', // 分类名称模糊搜索
-     *      'page' => 1, //  页码
-     *      'limit' => 15, //  每页条数
-     * ]
-     * @param mixed $isAll // 是否获取所有数据 默认否
-     * date 2023/03/28 17:05
-     */
-    public static function list($param = [], $isAll = false)
-    {
-        $where = self::getCondition($param);
-        if ($isAll){
-            return   NoticeTypes::where($where)->select('id','name')->get();
-        }else {
-            $pageSize = $param['limit'] ?? 15;
-            return   NoticeTypes::where($where)->select('id', 'name', 'created_at')->paginate($pageSize);
-        }
-
-    }
-
-    /**
-     *  拼接查询条件
-     * name: getCondition
-     * @param mixed $param
-     * @return \string[][]
-     * date 2023/03/28 17:19
-     */
-    private static function getCondition(mixed $param)
-    {
-        $where = [['is_deleted', '=', '0']];
-        if (isset($param['name']) && !empty($param['name'])) {
-            $where[] = ['name', 'like', "%" . $param['name'] . "%"];
-        }
-        return $where;
-    }
-
-    /**
-     *  删除分类,软删除
-     * name: del
-     * @param $id
-     * @return mixed
-     * date 2023/03/29 11:05
-     */
-    public static function del($id)
-    {
-        return self::getModel()->updateBy($id,['is_deleted' => 1,'deleted_at' => date("Y-m-d H:i:s")]);
-    }
-}

+ 0 - 248
modules/Video/Services/Notice/NoticesService.php

@@ -1,248 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:NoitceService.php
- * @Created by gnitif
- * @Date: 2023/3/27
- * @Time: 11:54
- */
-
-
-namespace Modules\System\Services\Notice;
-
-use Catch\Exceptions\FailedException;
-use Illuminate\Database\Eloquent\Model;
-use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Facades\DB;
-use Modules\System\Models\Notices;
-use Modules\System\Models\UserNotice;
-use Modules\Permissions\Models\Roles;
-use Modules\User\Models\User;
-use PharIo\Manifest\Author;
-
-class NoticesService
-{
-
-    protected static function getModel()
-    {
-        return new Notices();
-    }
-
-    /**
-     *  添加通知
-     * name: addNotice
-     * @param array $param
-     *  $param = [
-     *      'title' => '测试', // 通知标题
-     *      'notice_type_id' =>  2, // 通知分类id
-     *      'type' => '2', // 通知人群 1全部 2,指定人,3指定角色
-     *      'notice_obj' => [['id' =>  1,'name' => "超管"]] , // 通知对象
-     *      'is_popup' => '1', // 是否是弹窗 1弹窗  0 普通
-     *       'content' => '312312', // 通知内容
-     * ];
-     *
-     * date 2023/03/29 14:25
-     */
-    public static function addNotice(array $param)
-    {
-
-        if ($param['type'] != 1 && (!isset($param['notice_obj']) || empty($param['notice_obj']))) {
-            throw new FailedException('通知对象不能为空!');
-        }
-
-        if ($param['type'] == 3) {
-            $roleIds = array_column($param['notice_obj'], 'id');
-            $userIds = DB::table('user_has_roles')->whereIn('role_id', $roleIds)->pluck('user_id')->toArray();
-        } else if ($param['type'] == 2) {
-            $userIds = array_column($param['notice_obj'], 'id');
-        } else {
-            $userIds = User::pluck('id')->toArray();
-            $param['notice_obj'] = [];
-        }
-        $param['user_ids'] = $userIds;
-        return self::getModel()->storeBy($param);
-    }
-
-    public static function delete($id)
-    {
-        return self::getModel()->updateBy($id, ['is_deleted' => 1, 'deleted_at' => get_date()]);
-    }
-
-    /**
-     *  获取通知详情
-     * name: getDetail
-     * @param $id
-     * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|Notices[]
-     * date 2023/03/29 15:12
-     */
-    public static function getDetail($id)
-    {
-        $info = Notices::leftJoin('notice_types', 'notice_types.id', 'notices.notice_type_id')
-            ->select('notices.*', 'notice_types.name as notice_type_name')->where('notices.id', $id)->first();
-        return $info;
-    }
-
-    /**
-     *  更新
-     * name: update
-     * @param $id
-     * @param array $param
-     * date 2023/03/29 18:32
-     */
-    public static function update($id, array $param)
-    {
-       return  self::getModel()->updateBy($id, $param);
-    }
-
-    /**
-     *  管理员操作通知列表
-     * name: list
-     * @return mixed
-     * date 2023/03/29 22:49
-     */
-    public static function  list()
-    {
-        $list = self::getModel()->setBeforeGetList(function ($query) {
-            return $query->where('is_deleted', 0)->orderBy('created_at','desc');
-        })->getList();
-        if (!$list->isEmpty()) {
-            $cate = NoitceTypeService::list([], true);
-            if ($cate->isEmpty()) {
-                $cate = [];
-            } else {
-                $cate = array_column($cate->toArray(), null, 'id');
-            }
-
-            foreach ($list as $value) {
-                $value->notice_type_txt = $cate[$value->notice_type_id]['name'] ?? "";
-                $value->type_txt = $value->type == 1 ? "全部" : ($value->type == 2 ? "指定用户" : "指定角色");
-            }
-        }
-        return $list;
-    }
-
-    /**
-     * 我的通知
-     * name: myNoticesList
-     * date 2023/03/29 22:49
-     */
-    public static function myNoticesList($param = [])
-    {
-        $type = $param['type'] ?? "";
-        $noticeTypeId = $param['notice_type_id'] ?? 0;
-        $title = $param['title'] ?? "";
-        $pageSize = $param['limit'] ?? 0;
-        $pageSize = $pageSize < 1 ? 15 : $pageSize;
-        $userId = Auth::guard(getGuardName())->id();
-        $where = [
-            ['user_notice.is_deleted', '=', 0],
-            ['user_notice.user_id', '=', $userId],
-            ['notices.is_deleted', '=', 0],
-            ['user_notice.is_deleted', '=', 0],
-        ];
-        if ($type) {
-            $where[] = ['notices.type', '=', $type];
-        }
-        if ($noticeTypeId) {
-            $where[] = ['notices.notice_type_id', '=', $noticeTypeId];
-        }
-        if ($title) {
-            $where[] = ['notices.title', 'like', "%" . $title . "%"];
-        }
-
-        $list = UserNotice::leftJoin('notices', 'notices.id', "user_notice.notice_id")->where($where)->select('notices.id', 'notices.title', 'notices.is_popup', "user_notice.is_read", 'notices.created_at')
-            ->orderBy('notices.created_at', 'desc')->orderBy('sort', 'desc')->paginate($pageSize);
-        if (!$list->isEmpty()) {
-            foreach ($list as $val) {
-                $val->is_read_txt = $val->is_read == 1 ? "已读" : "未读";
-            }
-        }
-        return $list;
-    }
-
-    /**
-     *  设置已读
-     * name: setRead
-     * @param $id
-     * date 2023/03/29 23:51
-     */
-    public static function setRead($id)
-    {
-        $userId = Auth::guard(getGuardName())->id();
-        return UserNotice::where('user_id', $userId)->where('notice_id', $id)->update(['is_read' => 1, 'read_at' => get_date()]);
-    }
-
-    /**
-     *  用户删除
-     * name: userDel
-     * @param $id
-     * date 2023/03/29 23:55
-     */
-    public static function userDel($id)
-    {
-        $userId = Auth::guard(getGuardName())->id();
-        return UserNotice::where('user_id', $userId)->where('notice_id', $id)->update(['is_deleted' => 1, 'deleted_at' => get_date()]);
-    }
-
-    /**
-     *  阅读详情
-     * name: detail
-     * @param $id
-     * @return Notices
-     * date 2023/03/30 00:09
-     */
-    public static function detail($id)
-    {
-        return Notices::where('id', $id)->where('is_deleted', 0)->select('title', 'id', 'is_popup', 'content')->first();
-    }
-
-    /**
-     *  获取指定对象选择项
-     * name: objOption
-     * @param $type
-     * @param string $name
-     * @return array
-     * date 2023/03/30 10:23
-     */
-    public static function objOption($type, $name = ""): mixed
-    {
-        if ($type == 'user') {
-            if ($name) {
-                return  User::where("username", 'like', "%" . $name . "%")->without(['roles','jobs'])->select('id','username as name')->get();
-            }
-            return User::select('id','username as name')->without(['roles','jobs'])->get();
-        } else if ($type == "role") {
-            if ($name) {
-                return Roles::where("role_name", 'like', "%" . $name . "%")->select('id','role_name as name')->get();
-            }
-            return Roles::select('id','role_name as name')->get();
-        }
-        return [];
-    }
-
-    /**
-     *  一条获取弹窗信息
-     * name: getPopup
-     * @return Model|UserNotice|object|null
-     * date 2023/03/30 16:45
-     */
-    public static function getPopup()
-    {
-        $where = [
-            ['user_notice.is_deleted', '=', 0],
-            ['user_notice.user_id', '=',  Auth::guard(getGuardName())->id()],
-            ['notices.is_deleted', '=', 0],
-            ['notices.is_popup', '=', 1],
-            ['user_notice.is_read', '=', 0],
-        ];
-
-         $info =  UserNotice::leftJoin('notices', 'notices.id', "user_notice.notice_id")->where($where)->select('notices.id', 'notices.title', 'notices.content')
-             ->orderBy('notices.created_at', 'desc')->orderBy('sort', 'desc')->first();
-         if (empty($info)){
-             return  [];
-         }
-         return  $info;
-    }
-
-
-}

+ 60 - 0
modules/Video/Services/VideoService.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace Modules\Video\Services;
+
+use Illuminate\Support\Facades\DB;
+use Modules\Common\Errors\Errors;
+use Modules\Common\Exceptions\CommonBusinessException;
+
+class VideoService
+{
+    public static function updateVideoChargeInfo($video, $userContext)
+    {
+        if ($userContext['loginUserRoles']->contains('administrator')) {
+            $video->charge_sequence = $video->d_charge_sequence;
+            $video->charge_coin = $video->d_charge_coin;
+            return;
+        }
+        if ($userContext['loginUserRoles']->contains('company')) {
+            if ($userContext['loginUser']->id == $userContext['operateUser']->id) {
+                $video->charge_sequence = $video->d_charge_sequence;
+                $video->charge_coin = $video->d_charge_coin;
+                return;
+            } else {
+                $videoUserConfig = self::getVideoUserConfig($userContext['operateUser']->id, $video->id);
+                $video->charge_sequence = $videoUserConfig->charge_sequence ?? $video->d_charge_sequence;
+                $video->charge_coin = $videoUserConfig->charge_coin ?? $video->d_charge_coin;
+                return;
+            }
+        }
+        if ($userContext['loginUserRoles']->contains('optimizer')) {
+            $videoUserConfig = self::getVideoUserConfig($userContext['loginUser']->id, $video->id);
+            $video->charge_sequence = $videoUserConfig->charge_sequence ?? $video->d_charge_sequence;
+            $video->charge_coin = $videoUserConfig->charge_coin ?? $video->d_charge_coin;
+            return;
+        }
+    }
+
+    private static function getVideoUserConfig($uid, $videoId)
+    {
+        return DB::table('video_user_config')
+            ->where(['is_enabled' => 1, 'uid' => $uid, 'video_id' => $videoId])->first();
+
+    }
+
+    /**
+     * 通过主键查询短剧信息,没有找到抛出异常
+     * @param $videoId
+     * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Query\Builder|object|null
+     */
+    public static function getVideoByIdOrException($videoId)
+    {
+        $video = DB::table('videos')
+            ->where(['id' => $videoId])
+            ->first();
+        if (!$video) {
+            CommonBusinessException::throwError(Errors::VIDEO_NOT_EXISTS);
+        }
+        return $video;
+    }
+}

+ 5 - 0
modules/Video/routes/route.php

@@ -3,12 +3,17 @@
 use Illuminate\Support\Facades\Route;
 use Modules\System\Http\Controllers\NoticesController;
 use Modules\System\Http\Controllers\NoticeTypesController;
+use Modules\Video\Http\Controllers\EpisodeController;
 use Modules\Video\Http\Controllers\VideoController;
 
 Route::prefix('videoStock')->group(function () {
     Route::get('video/list', [VideoController::class, 'list']);
+    Route::get('episode/list', [EpisodeController::class, 'list']);
+
 
     Route::post('video/update', [VideoController::class, 'update']);
     Route::post('video/add', [VideoController::class, 'add']);
+    Route::post('video/setChargeConfig', [VideoController::class, 'setChargeConfig']);
+    Route::post('episode/add', [EpisodeController::class, 'add']);
 });
 

+ 4 - 4
tests/UsedTestCase.php

@@ -13,11 +13,11 @@ abstract class UsedTestCase extends BaseTestCase
     {
         parent::setUp(); // TODO: Change the autogenerated stub
         $tokenInfo = $this->post('http://localhost/api/login', [
-//            'email' => 'catch@admin.com',
-//            'password' => 'catchadmin',
+            'email' => 'catch@admin.com',
+            'password' => 'catchadmin',
             'remember' => false,
-            'email' => 'xiaoli@qq.com',
-            'password' => 'Qaz123',
+//            'email' => 'xiaoli@qq.com',
+//            'password' => 'Qaz123',
 //        'email' => 'aa4@test.com',
 //            'password' => '123',
         ])->json();

+ 36 - 0
tests/Video/Http/Controllers/EpisodeControllerTest.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace Tests\Video\Http\Controllers;
+
+use Modules\Video\Http\Controllers\EpisodeController;
+use PHPUnit\Framework\TestCase;
+use Tests\UsedTestCase;
+
+class EpisodeControllerTest extends UsedTestCase
+{
+
+    public function testList()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/videoStock/episode/list', [
+            'video_id' => 1
+        ]);
+        $this->dumpJson($res);
+    }
+
+    public function testAdd()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/videoStock/episode/add', [
+            'video_id' => 2,
+            'videos' => [
+                ['name' => '01_xxx', 'duration' => 12342, 'url' => 'url1'],
+                ['name' => '02_xxx', 'duration' => 1222, 'url' => 'url2'],
+                ['name' => '03_xxx', 'duration' => 3342, 'url' => 'url3'],
+            ]
+        ]);
+        $this->dumpJson($res);
+    }
+}

+ 13 - 1
tests/Video/Http/Controllers/VideoControllerTest.php

@@ -64,7 +64,19 @@ class VideoControllerTest extends UsedTestCase
 //        'categoryId' => 4,
             'operateUserId' =>10
         ]);
-//        $this->dumpJson($res);
+        $this->dumpJson($res);
+//        $res->dump();
+    }
+
+    public function testsetChargeConfig() {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/videoStock/video/setChargeConfig',[
+            'id' => 1,
+            'chargeCoin' => 67,
+            'chargeType' => 1,
+            'chargeSequence' => 23
+        ]);
         $res->dump();
     }
 }