zhaoyang 2 лет назад
Родитель
Сommit
f9b7ebcbcd

+ 1 - 1
modules/Channel/Http/Controllers/AdvertiserController.php

@@ -36,7 +36,7 @@ class AdvertiserController extends CatchController
             'miniProgramIds.*' => 'required|integer'
         ]);
         $this->user->emailUnique($request->input('email'));
-        $request['roles'] = [(DB::table('roles')->where('identify', 'Investmenter')->value('id') ?? 0)];
+        $request['roles'] = [(DB::table('roles')->where('identify', 'optimizer')->value('id') ?? 0)];
         $this->user->storeBy($request->all());
         $this->user->pid = $this->getLoginUserId();
         $this->user->save();

+ 2 - 0
modules/Common/Errors/Errors.php

@@ -8,4 +8,6 @@ class Errors
     public const  USER_NOT_FOUND= [500002, '用户不存在'];
     public const  PARAM_EMPTY= [500003, '缺少参数'];
     public const  PARAM_ERROR= [500004, '参数错误'];
+    public const  NO_OPERATE_PERMISSION= [500003, '用户无操作权限'];
+    public const  VIDEO_NOT_EXISTS= [500004, '视频不存在'];
 }

+ 17 - 0
modules/Common/Exceptions/CommonBusinessException.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace Modules\Common\Exceptions;
+
+use Throwable;
+
+class CommonBusinessException extends \RuntimeException
+{
+    public function __construct($message = "", $code = 0, Throwable $previous = null)
+    {
+        parent::__construct($message, $code, $previous);
+    }
+
+    public static function throwError($error, Throwable $previous = null) {
+        throw (new static($error[1], $error[0], $previous));
+    }
+}

+ 38 - 1
modules/CpManage/Http/Requests/CpRequest.php

@@ -10,7 +10,44 @@
 
 namespace Modules\CpManage\Http\Requests;
 
-class CpRequest
+use Illuminate\Foundation\Http\FormRequest;
+use Modules\CpManage\Models\Cp\Cps;
+
+class CpRequest extends  FormRequest
 {
 
+    /**
+     * rules
+     *
+     * @return array
+     */
+    public function rules(): array
+    {
+        return [
+            'cp_name' => sprintf('required|unique:%s,%s,%s', Cps::class, 'cp_name', $this->get('cp_id')),
+            "cp_company" =>  "|required|string|min:1",
+            "cp_nick" =>  "|required|string|min:1",
+            "share_per" =>  "|required|Integer|min:0|max:100",
+            // "share_per_before" =>  "|required|Integer|min:1|max:100",
+            // "share_per_after" =>  "|required|Integer|min:1|max:100",
+        ];
+    }
+    /**
+     * messages
+     *
+     * @return string[]
+     */
+    public function messages(): array
+    {
+        return [
+            'cp_name.required' => 'cp名称必须填写',
+            'cp_name.unique' => 'cp名称已存在',
+            'cp_company' => '所属公司必填',
+            'cp_nick' => 'cp简称必填',
+            'address' => '公司地址必填',
+            "share_per" => "分成比例不正确",
+            "share_per_before" => "分成比例不正确",
+            "share_per_after" => "分成比例不正确",
+        ];
+    }
 }

+ 17 - 0
modules/Video/Exceptions/ContentBusinessException.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace Modules\ContentManage\Exceptions;
+
+use Throwable;
+
+class ContentBusinessException extends \RuntimeException
+{
+    public function __construct($message = "", $code = 0, Throwable $previous = null)
+    {
+        parent::__construct($message, $code, $previous);
+    }
+
+    public static function throwError($error, Throwable $previous = null) {
+        throw (new static($error[1], $error[0], $previous));
+    }
+}

+ 20 - 0
modules/Video/Exceptions/ContentManageForbidden.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace Modules\ContentManage\Exceptions;
+
+use Catch\Enums\Code;
+use Catch\Exceptions\CatchException;
+use Symfony\Component\HttpFoundation\Response;
+
+class ContentManageForbidden extends CatchException
+{
+    protected $message = 'permission forbidden';
+
+    protected $code = Code::PERMISSION_FORBIDDEN;
+
+
+    public function statusCode(): int
+    {
+        return Response::HTTP_FORBIDDEN;
+    }
+}

+ 9 - 0
modules/Video/Exceptions/Errors.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace Modules\ContentManage\Exceptions;
+
+class Errors
+{
+    public const REQUEST_HTTP_STATUS_ERROR = [500001, '请求上游接口返回http状态码有误'];
+    public const REQUEST_CODE_STATUS_ERROR = [500002, '请求上游接口返回code状态码有误'];
+}

+ 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;
+    }
+}

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

@@ -0,0 +1,81 @@
+<?php
+
+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
+{
+    // 当前登录用户
+    protected $currentUser;
+
+
+    /**
+     * 获取当前登录用户
+     * @return User
+     */
+    protected function getCurrentUser(): User {
+        if(!$this->currentUser) {
+            $this->currentUser = $this->getLoginUser();
+        }
+        return $this->currentUser;
+    }
+    /**
+     * 当前用户的所有的角色标识的结合
+     * @return Collection
+     */
+    protected function listUserRoles():Collection {
+        return $this->getCurrentUser()->roles->pluck('identify');
+    }
+
+    /**
+     * 当前用户是否是cp角色
+     * @return bool
+     */
+    public function userIsCp():bool {
+        return $this->listUserRoles()->contains('cp');
+    }
+
+    /**
+     * 如果当前用户是cp角色,返回cp_name,否则返回null
+     * @return string
+     */
+    public function getUserCpName():string|null {
+        if($this->userIsCp()) {
+            return DB::table('user_belong_to_cp')
+                ->where([
+                    'is_enabled' => 1,
+                    'user_id' => $this->getCurrentUser()->id,
+                ])->value('cp_name');
+        } else {
+            return null;
+        }
+    }
+
+    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');
+    }
+
+}

+ 184 - 0
modules/Video/Http/Controllers/VideoController.php

@@ -0,0 +1,184 @@
+<?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 VideoController extends CatchController
+{
+    use UserTrait;
+    use ValidatesRequests;
+
+    /**
+     * 短剧列表
+     * @param Request $request
+     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
+     */
+    public function list(Request $request) {
+
+        $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){
+                return $query->where('update_type', $updateType);
+            })->when($categoryId, function ($query, $categoryId){
+                return $query->where('category_id', $categoryId);
+            })->orderBy('id', 'desc')
+            ->paginate($request->integer('per_page', 15));
+        $userContext = $this->getUserContext($request->input('operateUserIdßßß'));
+        $allVideoCategory =  DB::table('video_category')
+            ->get()->keyBy('id');
+        foreach ($videos as $video) {
+            $this->updateVideoInfo($video, $userContext);
+            $video->category_str = $this->getCategoryStr($allVideoCategory, $video->category_id);
+        }
+
+        return $videos;
+    }
+
+    /**
+     * 订阅设置
+     * @param Request $request
+     * @throws \Illuminate\Validation\ValidationException
+     */
+    public function setChargeConfig(Request $request) {
+        $this->validate($request, [
+            'id' => 'required',
+            'chargeCoin' => 'required|integer|min:50|max:100',
+            'chargeType' => 'required|integer|in:1',
+            'chargeSequence' => 'required|integer|min:1|max:30'
+        ]);
+        $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') || 1 == $userContext['loginUser']->id) {
+            DB::table('videos')
+                ->where('id', $request->input('id'))
+                ->update([
+                    'd_charge_type' => $request->input('chargeType'),
+                    'd_charge_sequence' => $request->input('chargeSequence'),
+                    'd_charge_coin' => $request->input('chargeCoin'),
+                    'updated_at' => $now
+                ]);
+        } else {
+            DB::table('video_user_config')
+                ->where([
+                    'video_id' => $request->input('id'),
+                    'uid' => $userContext['loginUser']->id
+                ])->update(['is_enabled' => 0, 'updated_at' => $now]);
+            DB::table('video_user_config')
+                ->insert([
+                    'uid' => $userContext['loginUser']->id,
+                    'video_id' => $request->input('id'),
+                    'charge_type' => $request->input('chargeType'),
+                    'charge_sequence' => $request->input('chargeSequence'),
+                    'charge_coin' => $request->input('chargeCoin'),
+                    'updated_at' => $now,
+                    'created_at' => $now
+                ]);
+        }
+
+    }
+
+    /**
+     * 添加短剧
+     * @param Request $request
+     * @return int
+     * @throws \Illuminate\Validation\ValidationException
+     */
+    public function add(Request $request) {
+        $this->validate($request, [
+            'name' => 'required|string|max:128',
+            'total_episode_num' => 'required|integer',
+            'update_type' => 'required|integer|in:1,2',
+            'category_id' => 'required|integer',
+            'shelf_type' => 'required|integer|in:1,2',
+            'd_charge_sequence' => 'required|integer|min:1',
+            'd_charge_coin' => 'required|integer|min:1',
+            'cp_name' => 'required|string',
+            'cp_share_type' => 'required|integer|in:1,2,3',
+            'cover_image' => 'required|string'
+        ]);
+        $data = $request->all();
+        $now = date('Y-m-d H:i:s');
+        $data['created_at'] = $data['updated_at'] = $now;
+        if(2 == $request->integer('shelf_type')) {
+            $data['shelf_at'] = $now;
+        } else {
+            $data['shelf_at'] = null;
+        }
+        DB::table('videos')
+            ->insert($data);
+        return 1;
+    }
+
+    /**
+     * 更新短剧信息
+     * @param Request $request
+     * @return int
+     * @throws \Illuminate\Validation\ValidationException
+     */
+    public function update(Request $request) {
+        $this->validate($request, [
+            'id' => 'required',
+            'name' => 'required|string|max:128',
+            'total_episode_num' => 'required|integer',
+            'update_type' => 'required|integer|in:1,2',
+            'category_id' => 'required|integer',
+            'shelf_type' => 'required|integer|in:1,2',
+            'd_charge_sequence' => 'required|integer|min:1',
+            'd_charge_coin' => 'required|integer|min:1',
+            'cp_name' => 'required|string',
+            'cp_share_type' => 'required|integer|in:1,2,3',
+            'cover_image' => 'required|string'
+        ]);
+        $id = $request->input('id');
+        $data = $request->except('id', 'shelf_at');
+        $data['updated_at'] = date('Y-m-d H:i:s');
+        $video = VideoService::getVideoByIdOrException($request->input('id'));
+        if(2 == $request->integer('shelf_type') && 1 == $video->shelf_type) {
+            $data['shelf_at'] = $data['updated_at'];
+        }
+        DB::table('videos')
+            ->where('id', $id)
+            ->update($data);
+        return 1;
+    }
+
+
+
+    private function updateVideoInfo($video, $userContext) {
+        VideoService::updateVideoChargeInfo($video, $userContext);
+    }
+
+
+
+    private function getCategoryStr($allCategory,$categoryId) {
+        $category = $allCategory->get($categoryId);
+        if(!$category) {
+            return '';
+        } else {
+            $firstLevelStr = $allCategory->get($category->pid)->category_name ?? '';
+            $secondLevelStr = $category->category_name;
+            return trim(join('/', compact('firstLevelStr','secondLevelStr')), '/');
+        }
+    }
+}

+ 32 - 0
modules/Video/Installer.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace Modules\ContentManage;
+
+use Catch\Support\Module\Installer as ModuleInstaller;
+use Modules\ContentManage\Providers\ContentManageServiceProvider;
+
+class Installer extends ModuleInstaller
+{
+    protected function info(): array
+    {
+        // TODO: Implement info() method.
+        return [
+            'title' => '内容中台',
+            'name' => 'contentManage',
+            'path' => 'contentManage',
+            'keywords' => '内容中台',
+            'description' => '内容中台管理模块',
+            'provider' => ContentManageServiceProvider::class
+        ];
+    }
+
+    protected function requirePackages(): void
+    {
+        // TODO: Implement requirePackages() method.
+    }
+
+    protected function removePackages(): void
+    {
+        // TODO: Implement removePackages() method.
+    }
+}

+ 31 - 0
modules/Video/Providers/VideoServiceProvider.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace Modules\Video\Providers;
+
+use Catch\CatchAdmin;
+use Catch\Providers\CatchModuleServiceProvider;
+use Modules\ContentManage\Middlewares\ContentManageGate;
+
+class VideoServiceProvider extends CatchModuleServiceProvider
+{
+    /**
+     * middlewares
+     *
+     * @return string[]
+     */
+    protected function middlewares(): array
+    {
+       return [];
+    }
+
+    /**
+     * route path
+     *
+     * @return string|array
+     */
+    public function moduleName(): string|array
+    {
+        // TODO: Implement path() method.
+        return 'video';
+    }
+}

+ 10 - 0
modules/Video/README.md

@@ -0,0 +1,10 @@
+#内容中台管理模块
+关于内容中台 相关的后台接口,对外api接口,都写在这里
+配置文件放在: config目录下,读取配置文件示例:config('contentManage.zhushuyunpublicapi.public_domain');
+config("模块名.配置文件名.配置项");
+
+数据库模型文件放在:Models 目录下面
+服务层文件放在:Services 目录下面
+控制器放在:modules/ContentManage/Http/Controllers 目录下面
+中间件放在:modules/ContentManage/Middlewares 目录下面
+路由只能现在 modules/ContentManage/rout/route.php 文件里

+ 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;
+    }
+}

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

@@ -0,0 +1,19 @@
+<?php
+
+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']);
+});
+

+ 6 - 4
tests/UsedTestCase.php

@@ -13,11 +13,13 @@ 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();
         $this->token = $tokenInfo['data']['token'];
     }

+ 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);
+    }
+}

+ 82 - 0
tests/Video/Http/Controllers/VideoControllerTest.php

@@ -0,0 +1,82 @@
+<?php
+
+namespace Tests\Video\Http\Controllers;
+
+use Modules\Video\Http\Controllers\VideoController;
+use PHPUnit\Framework\TestCase;
+use Tests\UsedTestCase;
+
+class VideoControllerTest extends UsedTestCase
+{
+
+    public function testAdd()
+    {
+        $data = [
+            'name' => 'test1-112',
+            'total_episode_num' => 10,
+            'update_type' => 1,
+            'category_id' => 4,
+            'shelf_type' => 2,
+            'd_charge_sequence' => 3,
+            'd_charge_coin' => 10,
+            'cp_name' => 'kanshu1',
+            'cp_share_type' => 1,
+            'cover_image' => 'https://www.baidu.com'
+        ];
+
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/videoStock/video/add', $data);
+
+        $this->dumpJson($res);
+    }
+
+    public function testUpdate() {
+        $data = [
+            'name' => 'test1-114',
+            'total_episode_num' => 10,
+            'update_type' => 2,
+            'category_id' => 4,
+            'shelf_type' => 1,
+            'd_charge_sequence' => 3,
+            'd_charge_coin' => 10,
+            'cp_name' => 'kanshu1',
+            'cp_share_type' => 1,
+            'cover_image' => 'https://www.baidu.com',
+            'id' => 2,
+        ];
+
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/videoStock/video/update', $data);
+        $this->dumpJson($res);
+    }
+
+    public function testList() {
+        $query = [
+            'operateUserId' => null,
+        ];
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/videoStock/video/list', [
+//            'videoName' => '112',
+//        'updateType' => 2,
+//        'categoryId' => 4,
+            'operateUserId' =>10
+        ]);
+        $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();
+    }
+}