فهرست منبع

Merge branch 'master' of qk:zy_duanju/duanju_manage into test

admin 2 سال پیش
والد
کامیت
b63434ed3a
34فایلهای تغییر یافته به همراه530 افزوده شده و 393 حذف شده
  1. 26 0
      modules/Channel/Http/Controllers/UserMiniprogramController.php
  2. 6 6
      modules/Channel/Installer.php
  3. 1 1
      modules/Channel/Models/BaseModel.php
  4. 1 2
      modules/Channel/Models/NoticeTypes.php
  5. 1 1
      modules/Channel/Models/Notices.php
  6. 14 0
      modules/Channel/Models/UserHasMiniprograms.php
  7. 1 1
      modules/Channel/Models/UserNotice.php
  8. 14 0
      modules/Channel/Models/Users.php
  9. 0 2
      modules/Channel/Providers/ChannelServiceProvider.php
  10. 35 0
      modules/Channel/Services/User/UserService.php
  11. 4 0
      modules/Channel/routes/route.php
  12. 2 0
      modules/Common/Errors/Errors.php
  13. 40 0
      modules/Manage/Enmus/MiniprogramType.php
  14. 76 0
      modules/Manage/Http/Controllers/MiniprogramController.php
  15. 88 0
      modules/Manage/Http/Controllers/UserMiniprogramController.php
  16. 41 0
      modules/Manage/Http/Requests/MiniprogramRequest.php
  17. 30 0
      modules/Manage/Models/BaseModel.php
  18. 20 0
      modules/Manage/Models/Miniprogram.php
  19. 20 0
      modules/Manage/Providers/ManageServiceProvider.php
  20. 12 0
      modules/Manage/config/miniprogram.php
  21. 38 0
      modules/Manage/routes/route.php
  22. 1 0
      modules/User/Models/User.php
  23. 0 9
      phpunit.xml
  24. 0 27
      tests/Common/Http/Controllers/OptionControllerTest.php
  25. 0 17
      tests/Common/Support/Trace/CustomizeLoggerTest.php
  26. 0 97
      tests/ContentManage/Http/Controllers/BookControllerTest.php
  27. 0 22
      tests/ContentManage/Http/Controllers/CpListControllerTest.php
  28. 0 62
      tests/ContentManage/Http/Controllers/CpSubscribeStatisticDataControllerTest.php
  29. 0 57
      tests/ContentManage/Output/OutputTest.php
  30. 0 18
      tests/ContentManage/Services/CP/SyncSubscribeTest.php
  31. 0 52
      tests/ContentManage/Services/CpManage/BookSettlementTest.php
  32. 1 1
      tests/Feature/ExampleTest.php
  33. 58 0
      tests/Feature/MiniprogramTest.php
  34. 0 18
      tests/Unit/ExampleTest.php

+ 26 - 0
modules/Channel/Http/Controllers/UserMiniprogramController.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace Modules\Channel\Http\Controllers;
+
+use Catch\Base\CatchController;
+use Illuminate\Http\Request;
+use Modules\User\Models\User;
+use Modules\Channel\Models\UserHasMiniprograms;
+
+class UserMiniprogramController extends CatchController
+{
+    public function __construct(
+        protected readonly User $user,
+        protected readonly UserHasMiniprograms $userHasMiniprograms
+    ) {
+    }
+
+    public function index(Request $request)
+    {
+          return $this->userHasMiniprograms->join('miniprogram','miniprogram.id','=','user_has_miniprograms.miniprogram_id')
+          ->where('user_has_miniprograms.is_enabled',1)
+          ->where('uid',$this->user->id)
+          ->select('user_has_miniprograms.miniprogram_id','miniprogram.name','miniprogram.play_name')
+          ->get();
+    }
+}

+ 6 - 6
modules/Channel/Installer.php

@@ -1,9 +1,9 @@
 <?php
 
-namespace Modules\ContentManage;
+namespace Modules\Channel;
 
 use Catch\Support\Module\Installer as ModuleInstaller;
-use Modules\ContentManage\Providers\ContentManageServiceProvider;
+use Modules\Channel\Providers\ChannelServiceProvider;
 
 class Installer extends ModuleInstaller
 {
@@ -11,12 +11,12 @@ class Installer extends ModuleInstaller
     {
         // TODO: Implement info() method.
         return [
-            'title' => '内容中台',
-            'name' => 'contentManage',
-            'path' => 'contentManage',
+            'title' => '渠道管理',
+            'name' => 'channel',
+            'path' => 'channel',
             'keywords' => '内容中台',
             'description' => '内容中台管理模块',
-            'provider' => ContentManageServiceProvider::class
+            'provider' => ChannelServiceProvider::class
         ];
     }
 

+ 1 - 1
modules/Channel/Models/BaseModel.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Modules\System\Models;
+namespace Modules\Channel\Models;
 
 use Catch\Base\CatchModel as Model;
 use Illuminate\Database\Eloquent\Builder;

+ 1 - 2
modules/Channel/Models/NoticeTypes.php

@@ -1,7 +1,6 @@
 <?php
 
-namespace Modules\System\Models;
-
+namespace Modules\Channel\Models;
 
 
 class NoticeTypes extends BaseModel

+ 1 - 1
modules/Channel/Models/Notices.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Modules\System\Models;
+namespace Modules\Channel\Models;
 
 
 class Notices extends BaseModel

+ 14 - 0
modules/Channel/Models/UserHasMiniprograms.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace Modules\Channel\Models;
+
+
+class UserHasMiniprograms extends BaseModel
+{
+    protected $table = 'user_has_miniprograms';
+
+    protected $fillable = [
+        'id', 'uid', 'miniprogram_id', 'is_enabled', 'created_at', 'updated_at'
+    ];
+
+}

+ 1 - 1
modules/Channel/Models/UserNotice.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Modules\System\Models;
+namespace Modules\Channel\Models;
 
 
 class UserNotice extends BaseModel

+ 14 - 0
modules/Channel/Models/Users.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace Modules\Channel\Models;
+
+
+class Users extends BaseModel
+{
+    protected $table = 'users';
+
+    protected $fillable = [
+        'id', 'username', 'password', 'email', 'avatar', 'remember_token', 'department_id', 'creator_id', 'status', 'login_ip', 'login_at', 'created_at', 'updated_at', 'deleted_at', 'pid', 'remark', 
+    ];
+
+}

+ 0 - 2
modules/Channel/Providers/ChannelServiceProvider.php

@@ -2,9 +2,7 @@
 
 namespace Modules\Channel\Providers;
 
-use Catch\CatchAdmin;
 use Catch\Providers\CatchModuleServiceProvider;
-use Modules\ContentManage\Middlewares\ContentManageGate;
 
 class ChannelServiceProvider extends CatchModuleServiceProvider
 {

+ 35 - 0
modules/Channel/Services/User/UserService.php

@@ -0,0 +1,35 @@
+<?php
+/**
+ * ${CARET}
+ * @file:NoitceService.php
+ * @Created by gnitif
+ * @Date: 2023/3/27
+ * @Time: 11:54
+ */
+
+
+namespace Modules\Channel\Services\User;
+
+use Modules\Channel\Models\Users;
+
+class UserService {
+
+
+    public static function listByRole(string $identify, array $field){
+        return Users::join('user_has_roles','user_has_roles.user_id','=','users.id')
+        ->join('roles','roles.id','=','user_has_roles.role_id')
+        ->where('roles.identify',$identify)
+        ->select($field)
+        ->get();
+    }
+
+
+    public static function getUserInfo(int $uid,array $field){
+        return Users::join('user_has_roles','user_has_roles.user_id','=','users.id')
+        ->join('roles','roles.id','=','user_has_roles.role_id')
+        ->where('users.id',$uid)
+        ->select($field)
+        ->first();
+    }
+
+}

+ 4 - 0
modules/Channel/routes/route.php

@@ -2,6 +2,7 @@
 
 use Illuminate\Support\Facades\Route;
 use Modules\Channel\Http\Controllers\AdvertiserController;
+use Modules\Channel\Http\Controllers\UserMiniprogramController;
 use Modules\System\Http\Controllers\NoticesController;
 use Modules\System\Http\Controllers\NoticeTypesController;
 
@@ -11,5 +12,8 @@ Route::prefix('channel')->group(function () {
 
     Route::get('advertiser/listAdvertiser', [AdvertiserController::class, 'listAdvertiser']);
     Route::get('advertiser/getAdvertiser', [AdvertiserController::class, 'getAdvertiser']);
+
+    Route::get('miniprogram/list', [UserMiniprogramController::class, 'index']);
+
 });
 

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

@@ -6,6 +6,8 @@ class Errors
 {
     public const  EMAIL_EXISTS= [500001, '邮箱已经被使用'];
     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, '视频不存在'];
 }

+ 40 - 0
modules/Manage/Enmus/MiniprogramType.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace Modules\Manage\Enmus;
+
+use Catch\Enums\Enum;
+
+
+enum MiniprogramType: int implements Enum
+{
+    case WEIXIN = 1; // 全部数据
+    case BYTECODE = 2; // 自定义数据
+
+
+    public function value(): int
+    {
+        return match ($this) {
+            self::WEIXIN => 1,
+            self::BYTECODE => 2
+        };
+    }
+
+    public function name(): string
+    {
+        return match ($this) {
+            self::WEIXIN => '微信小程序',
+            self::BYTECODE => '字节小程序',
+        };
+    }
+
+    /**
+     * assert value
+     *
+     * @param int $value
+     * @return bool
+     */
+    public function assert(int $value): bool
+    {
+       return $this->value === $value;
+    }
+}

+ 76 - 0
modules/Manage/Http/Controllers/MiniprogramController.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace Modules\Manage\Http\Controllers;
+
+use Illuminate\Routing\Controller;
+use Illuminate\Http\Request;
+use Modules\Manage\Enmus\MiniprogramType;
+use Modules\Manage\Http\Requests\MiniprogramRequest;
+use Modules\Manage\Models\Miniprogram;
+use Log;
+
+class MiniprogramController extends Controller
+{
+
+    public function __construct(protected readonly Miniprogram $miniprogram)
+    {
+        
+    }
+
+    public function index(Request $request)
+    {
+        $name = $request->get('name');
+        $play_name = $request->get('play_name');
+        $company = $request->get('company');
+        $where = [];
+        if($name){
+            $where[] = ['name','like','%'.$name.'%']; 
+        }
+        if($play_name){
+            $where[] = ['play_name','like','%'.$play_name.'%']; 
+        }
+        if($company){
+            $where[] = ['company','like','%'.$company.'%']; 
+        }
+        return $this->miniprogram->where($where)->paginate(20)->map(function($item,$k){
+            $item->type_name = MiniprogramType::from($item->type)->name();
+            return $item;
+        });
+    }
+
+    public function store(MiniprogramRequest $request)
+    {
+        $validate_result = $request->validated();
+        $validate_result['remark'] = $request->post('remark','') ?? '';
+        return $this->miniprogram->create($validate_result)->toArray();
+
+    }
+
+    public function show($id)
+    {
+        return $this->miniprogram->find($id)->toArray();
+    }
+
+
+    public function update($id, MiniprogramRequest $request)
+    {
+        $validate_result = $request->validated();
+        if($request->post('remark','')){
+            $validate_result['remark'] = $request->post('remark','');
+        }
+        $this->miniprogram->where('id',$id)->update($validate_result);
+        return [];
+    }
+
+    public function destroy($id)
+    {
+
+    }
+
+
+    public function typeList(){
+        $type_list =  MiniprogramType::cases();
+        $data = array_map( fn($item)=>['name'=>$item->name(),'value'=>$item->value()],$type_list );
+        return $data;
+    }
+}

+ 88 - 0
modules/Manage/Http/Controllers/UserMiniprogramController.php

@@ -0,0 +1,88 @@
+<?php
+
+namespace Modules\Manage\Http\Controllers;
+
+use Catch\Base\CatchController;
+use Illuminate\Http\Request;
+use Modules\Channel\Models\UserHasMiniprograms;
+use Modules\Channel\Services\User\UserService;
+use Modules\Channel\Exceptions\ChannelBusinessException;
+use Modules\Common\Errors\Errors;
+use Modules\Manage\Models\Miniprogram;
+use Log;
+
+class UserMiniprogramController extends CatchController
+{
+
+    const  COMPANY_ROLE = 'company';
+    public function __construct(
+        protected readonly UserHasMiniprograms $userHasMiniprograms,
+        protected readonly Miniprogram $miniprogram
+        )
+    {
+        
+    }
+
+
+
+    public function allocationStore($miniprogram_id,Request $request)
+    {
+        $uids  = $request->post('uids');
+        $action = $request->post('action');
+        if(empty($miniprogram_id) || empty($uids) || empty($action) || !in_array($action,['on','off'])){
+            ChannelBusinessException::throwError(Errors::PARAM_EMPTY);
+        }
+
+        $miniprogram_info =  $this->miniprogram->find($miniprogram_id);
+        if(!$miniprogram_info || $miniprogram_info->status == 0){
+            ChannelBusinessException::throwError(Errors::PARAM_ERROR);
+        }
+
+        collect(explode(',',$uids))->filter(function (int $value, int $key) use($miniprogram_id,$action){
+            $user_simple = UserService::getUserInfo($value,['roles.identify']);
+            if($user_simple && $user_simple->identify == self::COMPANY_ROLE){
+                $result = $this->userHasMiniprograms->where('uid',$value)->where('miniprogram_id',$miniprogram_id)->first();
+                if($action == 'off'){
+                    if($result){
+                        $result->is_enabled = 0;
+                        $result->save();
+                    }
+                    return true;
+                }
+                if($result){
+                    if($result->is_enabled == 0){
+                        $result->is_enabled = 1;
+                        $result->save();
+                    }
+                    return true;
+                }
+                $this->userHasMiniprograms->create([
+                    'uid'=>$value,'miniprogram_id'=>$miniprogram_id,'is_enabled'=>1
+                ]);
+                return true;
+            }
+            return false;
+        });
+
+        return [];
+
+    }
+
+
+
+    public function getAllocationInfo($miniprogram_id){
+        $all_company_account = UserService::listByRole(self::COMPANY_ROLE,['users.username','users.id']);
+        return $all_company_account->map(function ($item,$key) use($miniprogram_id) {
+            $info = $this->userHasMiniprograms->where('uid',$item->id)->where('miniprogram_id',$miniprogram_id)->where('is_enabled',1)->count();
+            if($info){
+                $item->user_has_miniprogram = 1;
+                $item->user_has_miniprogram_flag = 'on';
+            }else{
+                $item->user_has_miniprogram = 0;
+                $item->user_has_miniprogram_flag = 'off';
+            }
+            return $item;
+        })->groupBy('user_has_miniprogram_flag')->all();
+    }
+
+}

+ 41 - 0
modules/Manage/Http/Requests/MiniprogramRequest.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace Modules\Manage\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+use Modules\Manage\Enmus\MiniprogramType;
+use Illuminate\Validation\Rule;
+
+class MiniprogramRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     */
+    public function authorize(): bool
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
+     */
+    public function rules(): array
+    {
+        return [
+            'name'=> 'required|max:50',
+            'play_name'=> 'required|max:100',
+            'company'=> 'required|max:255',
+            'type'=> [
+                'required',
+                Rule::in( array_map( fn($item)=>$item->value(),MiniprogramType::cases())),
+            ],
+            'appsecret'=>'required|min:30',
+            'appid'=>'required|unique:miniprogram|min:18',
+            'status'=>'in:0,1'
+        ];
+    }
+}
+
+

+ 30 - 0
modules/Manage/Models/BaseModel.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace Modules\Manage\Models;
+
+use Catch\Base\CatchModel as Model;
+use Illuminate\Database\Eloquent\Builder;
+
+
+abstract class BaseModel extends Model
+{
+
+    protected array $defaultHidden = [];
+
+    protected array $defaultCasts = [
+        'created_at' => 'datetime:Y-m-d H:i:s',
+
+        'updated_at' => 'datetime:Y-m-d H:i:s',
+    ];
+    protected $dateFormat = '';
+
+    public static function bootSoftDeletes(): void{
+
+    }
+
+
+    public function scopeActive(Builder $query): void
+    {
+        $query->where($this->table.'.is_enabled', 1);
+    }
+}

+ 20 - 0
modules/Manage/Models/Miniprogram.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace Modules\Manage\Models;
+
+
+class Miniprogram extends BaseModel
+{
+
+    protected string $sortField = 'id';
+
+    // 排序规则
+    protected bool $sortDesc = true;
+
+    protected $table = 'miniprogram';
+
+    protected $fillable = [
+        'id', 'name', 'company', 'type', 'appid', 'appsecret', 'status', 'remark', 'play_name','created_at', 'updated_at'
+    ];
+
+}

+ 20 - 0
modules/Manage/Providers/ManageServiceProvider.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace Modules\Manage\Providers;
+
+use Catch\CatchAdmin;
+use Catch\Providers\CatchModuleServiceProvider;
+
+class ManageServiceProvider extends CatchModuleServiceProvider
+{
+    /**
+     * route path
+     *
+     * @return string
+     */
+    public function moduleName(): string
+    {
+        // TODO: Implement path() method.
+        return 'manage';
+    }
+}

+ 12 - 0
modules/Manage/config/miniprogram.php

@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * 小程序配置
+ */
+return [
+    
+    'typelist'=>[
+        'WEIXIN','BYTECODE'
+    ],
+    
+];

+ 38 - 0
modules/Manage/routes/route.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+use Modules\Manage\Http\Controllers\MiniprogramController;
+use Modules\Manage\Http\Controllers\UserMiniprogramController;
+
+Route::prefix('manage')->group(function(){
+    Route::prefix('miniprogram')->group(function () {
+        //类型列表
+        Route::get('typelist',[MiniprogramController::class,'typeList'])
+        ->withoutMiddleware(config('catch.route.middlewares'));
+
+        //添加
+        Route::post('store',[MiniprogramController::class,'store'])
+        ->withoutMiddleware(config('catch.route.middlewares'));
+
+        //小程序列表
+        Route::get('index',[MiniprogramController::class,'index'])
+        ->withoutMiddleware(config('catch.route.middlewares'));
+
+        //小程序详情
+        Route::get('show/{id}',[MiniprogramController::class,'show'])
+        ->withoutMiddleware(config('catch.route.middlewares'));
+
+         //小程序详情
+         Route::post('/update{id}',[MiniprogramController::class,'update'])
+         ->withoutMiddleware(config('catch.route.middlewares'));
+
+         //小程序分配列表
+         Route::get('allocation/{miniprogram_id}',[UserMiniprogramController::class,'getAllocationInfo'])
+         ->withoutMiddleware(config('catch.route.middlewares'));
+        //分配小程序
+         Route::post('allocation/{miniprogram_id}',[UserMiniprogramController::class,'allocationStore'])
+         ->withoutMiddleware(config('catch.route.middlewares'));
+
+    });
+});

+ 1 - 0
modules/User/Models/User.php

@@ -115,6 +115,7 @@ class User extends Model implements AuthenticatableContract
      * 否则展示所有isApp为false以及showApp对应的name的模块
      * @param string $showApp
      */
+    
     public function showPermissions($showApp = '') {
         $hiddenAppModuleNames = Modules::getAppModules()->reject(function ($module) use ($showApp) {
             return $showApp == $module['name'];

+ 0 - 9
phpunit.xml

@@ -11,15 +11,6 @@
         <testsuite name="Feature">
             <directory suffix="Test.php">./tests/Feature</directory>
         </testsuite>
-
-        <testsuite name="ContentOutput">
-            <directory suffix="Test.php">./tests/ContentManage/Output</directory>
-        </testsuite>
-
-        <testsuite name="ContentOutputBook">
-            <directory suffix="Test.php">./tests/ContentManage/Http/Controllers</directory>
-        </testsuite>
-
     </testsuites>
     <coverage processUncoveredFiles="true">
         <include>

+ 0 - 27
tests/Common/Http/Controllers/OptionControllerTest.php

@@ -1,27 +0,0 @@
-<?php
-
-namespace Tests\Common\Http\Controllers;
-
-use Modules\Common\Http\Controllers\OptionController;
-use Modules\Common\Support\Trace\TraceContext;
-use PHPUnit\Framework\TestCase;
-
-class OptionControllerTest extends \Tests\TestCase
-{
-
-    public function testIndex()
-    {
-        $res = $this->get('http://localhost/api/options/xiaoming');
-//        $res->dump();
-        dump(app(TraceContext::class)->getTraceInfo());
-        dump(app(TraceContext::class)->getTraceInfo());
-        dump($info1 = app(TraceContext::class)->getTraceInfo());
-        $channel = \Log::build([
-            'driver' => 'daily',
-            'path' => storage_path('logs/aa.log'),
-            'level' => 'debug'
-        ]);
-        \Log::stack([$channel])->info('hellow', ['traceInfo' => $info1]);
-        \Log::stack([$channel])->debug('hellow', ['traceInfo' => $info1]);
-    }
-}

+ 0 - 17
tests/Common/Support/Trace/CustomizeLoggerTest.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace Tests\Common\Support\Trace;
-
-use Modules\Common\Support\Trace\CustomizeLogger;
-use PHPUnit\Framework\TestCase;
-
-class CustomizeLoggerTest extends \Tests\TestCase
-{
-
-    public function testGetSubscribeLogger()
-    {
-        $logger = CustomizeLogger::getSubscribeLogger();
-        $logger->debug('dddd', ['kk' => 1]);
-        $logger->info('dddd', ['kk' => 1]);
-    }
-}

+ 0 - 97
tests/ContentManage/Http/Controllers/BookControllerTest.php

@@ -1,97 +0,0 @@
-<?php
-
-namespace Tests\ContentManage\Http\Controllers;
-
-use Illuminate\Foundation\Testing\RefreshDatabase;
-use Illuminate\Foundation\Testing\WithFaker;
-use Illuminate\Support\Facades\Storage;
-use Illuminate\Http\UploadedFile;
-use Tests\TestCase;
-
-class BookControllerTest extends TestCase
-{
-    /**
-     * A basic feature test example.
-     */
-    public function test_book_import(): void
-    {
-    $content = <<<EOT
-###第一章 前女友居然会逆袭
-大学毕业之后在武汉呆了半年,楚飞终于还是决定去深圳。
-之所以会做出这个决定,倒不是因为什么其它什么乱七八糟的理由,简单四个字,人穷志短!
-同样是刚刚毕业半年,楚飞现在每个月拿着不到两千块的工资勉强活着,但他的女朋友李冉却每个月可以拿四千的固定工资,而且刚刚发放的年底奖金,她竟然拿了十五万!这样折合起来她一个月接近一万七八千的薪水了,是楚飞的十倍!
-这就是差距
-###第二章 发光的残破青铜壶
-所以兜兜转转一圈之后,终于还是回到了原点么?
-
-现在承受着楚飞凶猛冲刺的不是他以为这辈子最爱的女人李冉,而是前女友张倩,一个对性爱无比热情无比投入的女人,偏偏也只有她这样的女人才能让楚飞玩的尽兴,玩的爽快,这还真是一件很搞笑的事情。因为在张倩身上楚飞可以不用压抑自己,更不用委屈自己,他想用什么姿势玩都行,想用多大的力道都行,甚至……想射在她身体上的任何位置都没问题!
-
-而在李冉身上,这一切永远只是奢望。
-
-###第三章 吃不饱的恐怖怪物
-楚飞先回宿舍去洗了个澡,然后收拾了一下自己的东西,准备踏踏实实的定下心干活。
-###第四章 妹是用来调教的
-楚飞真的愕住了,是真的。
-他从没有想过,那个自小时候就喜欢粘着他不停问问题的丫头,每次被他逗几句就会脸红心跳的诗诗丫头,来了深圳四年之后,却已经变成了这样……时间果然是一把残忍的杀猪刀,而现实也最是无情的恶魔,多少的美好都已经随风彻底的逝去。
-轻轻的走上去,楚飞在何诗诗的屁股上轻轻拍了拍,然后帮她拉起了内裤,“诗诗,我不是要跟你……”
-###第五章 男人应该胸有成竹
-发泄过后的男人总会有一阵空虚感,不过看着表妹把自己爆发出的东西一点不剩的全都吞了下去,楚飞突然却又觉得很有一种成就感。
-她……是我表妹呀!!
-EOT;
-        $file = UploadedFile::fake()->createWithContent("美女养成师.txt",$content);
-        $response = $this->postJson("api/contentManage/book/import",[
-            'cp_id'=>1,
-            'cp_name'=>'Testcp01111',
-            'book_name'=>'美女养成师师',
-            'author'=>'小林',
-            'channel'=>1,
-            'category_id'=>21,
-            'category_name'=>'武侠仙侠',
-            'vip_start'=>4,
-            'file'=>$file
-        ]);
-        print_r(json_decode($response->getContent(),1));   
-        $response->assertStatus(200);
-    }
-
-
-    public function test_create_book(): void
-    {
-        $path = 'book/NqpYgFL6yddDPSOnAwhIihk0DRjO7hEbOY3geJ6s.txt';
-        $response = $this->postJson("api/contentManage/book/createBook",[
-            'cp_id'=>1,
-            'cp_name'=>'Testcp01111',
-            'book_name'=>'美女养成的师师',
-            'author'=>'小林',
-            'channel'=>1,
-            'category_id'=>21,
-            'category_name'=>'武侠仙侠',
-            'vip_start'=>4,
-            'path'=>$path
-        ]);
-        print_r(json_decode($response->getContent(),1));   
-        $response->assertStatus(200);
-    }
-
-    
-    private $token;
-    protected function setUp(): void
-    {
-        parent::setUp(); // TODO: Change the autogenerated stub
-        $tokenInfo = $this->post('http://localhost/api/login', [
-            'email' => 'catch@admin.com',
-            'password' => 'catchadmin',
-            'remember' => false
-        ])->json();
-        $this->token = $tokenInfo['data']['token'];
-    }
-
-
-    public function testList()
-    {
-        $res = $this->withHeaders([
-            'Authorization' => 'Bearer '. $this->token,
-        ])->json('get', 'http://localhost/api/contentManage/book/list?is_export=1');
-        $res->dump();
-    }
-}

+ 0 - 22
tests/ContentManage/Http/Controllers/CpListControllerTest.php

@@ -1,22 +0,0 @@
-<?php
-
-namespace Tests\ContentManage\Http\Controllers;
-
-use Illuminate\Foundation\Testing\RefreshDatabase;
-use Illuminate\Foundation\Testing\WithFaker;
-use Illuminate\Support\Facades\Storage;
-use Illuminate\Http\UploadedFile;
-use Tests\TestCase;
-
-// php artisan test --testsuite=ContentOutputBook
-
-class CpListControllerTest extends TestCase{
-
-    public function test_cpP_collection(){
-
-        $response = $this->getJson("api/contentManage/cp/cpCollection?cp_id=1&cp_name=Testcp01111");
-        print_r(json_decode($response->getContent(),1));   
-        $response->assertStatus(200);
-
-    }
-}

+ 0 - 62
tests/ContentManage/Http/Controllers/CpSubscribeStatisticDataControllerTest.php

@@ -1,62 +0,0 @@
-<?php
-
-namespace Tests\ContentManage\Http\Controllers;
-
-use Modules\ContentManage\Http\Controllers\CpSubscribeStatisticDataController;
-use PHPUnit\Framework\TestCase;
-
-class CpSubscribeStatisticDataControllerTest extends \Tests\UsedTestCase
-{
-    public function testList()
-    {
-        $res = $this->withHeaders([
-            'Authorization' => 'Bearer '. $this->token,
-        ])->json('get','http://localhost/api/contentManage/cp/subscribeStatisticData/list?'.http_build_query([
-                'limit' => 15, 'page' => 1, 'book_name' => '小溪村的诱惑',
-                'cp_name' => 'quyuewang'
-            ]));
-        dump(\json_encode($res->json()));
-        $res->dump();
-    }
-
-    public function testlistStatistic()
-    {
-        $res = $this->withHeaders([
-            'Authorization' => 'Bearer '. $this->token,
-        ])->json('get','http://localhost/api/contentManage/cp/subscribeStatisticData/listStatistic?');
-        dump(\json_encode($res->json()));
-        $res->dump();
-    }
-
-    public function testMonthList()
-    {
-        $res = $this->withHeaders([
-            'Authorization' => 'Bearer '. $this->token,
-        ])->json('get','http://localhost/api/contentManage/cp/subscribeStatisticData/monthList?'.http_build_query([
-                'limit' => 15, 'page' => 1 , 'month' => '2022-07', 'cp_name' => 'Testcp01111'
-            ]));
-        dump(\json_encode($res->json()));
-        $res->dump();
-    }
-
-    public function testSaveFinalState() {
-        $res = $this->withHeaders([
-            'Authorization' => 'Bearer '. $this->token,
-        ])->json('post','http://localhost/api/contentManage/cp/subscribeStatisticData/saveFinalState', [
-            'id' => 1, 'final_state' => 'done'
-        ]);
-        dump(\json_encode($res->json()));
-        $res->dump();
-    }
-
-    public function testlistCpBooksMonthFinalAmount() {
-        $res = $this->withHeaders([
-            'Authorization' => 'Bearer '. $this->token,
-        ])->json('get','http://localhost/api/contentManage/cp/subscribeStatisticData/listCpMonthFinalAmount?'.http_build_query([
-                'cp_name' => '1221', 'month' => '2023-03'
-            ]));
-
-        $this->dumpJson($res);
-    }
-
-}

+ 0 - 57
tests/ContentManage/Output/OutputTest.php

@@ -1,57 +0,0 @@
-<?php
-
-namespace Tests\ContentManage\Output;
-
-// use Illuminate\Foundation\Testing\RefreshDatabase;
-use Tests\TestCase;
-
-/**
- * 输出测试
- */
-class OutputTest extends TestCase
-{
-    private string $query = 'channel_name=zhuishuyun&channel_key=123456';
-    private string $prefix = '/api/output/';
-    /**
-     * 
-     *书籍列表
-     * @return void
-     */
-    public function test_book_list()
-    {
-        $response = $this->getJson($this->prefix.'booklist?'.$this->query);
-        print_r(json_decode($response->getContent(),1));    
-        $response->assertStatus(200);
-    }
-
-    public function test_book_detail()
-    {
-        $response = $this->getJson($this->prefix.'bookdetail/1?'.$this->query);
-        print_r(json_decode($response->getContent(),1));   
-        $response->assertStatus(200);
-    }
-
-    public function test_chapter_list()
-    {
-        $response = $this->getJson($this->prefix.'chapterlist/1?'.$this->query);
-        //print_r(json_decode($response->getContent(),1));   
-        $response->assertStatus(200);
-    }
-
-
-
-    public function test_chapter_content()
-    {
-        $response = $this->getJson($this->prefix.'chaptercontent/1/chapterid/1?'.$this->query);
-        print_r(json_decode($response->getContent(),1));
-        $response->assertStatus(200)->assertJsonPath('code', 10000);
-    }
-
-
-    public function test_categories()
-    {
-        $response = $this->getJson($this->prefix.'listCategories?'.$this->query);
-        print_r(json_decode($response->getContent(),1));
-        $response->assertStatus(200)->assertJsonPath('code', 10000);
-    }
-}

+ 0 - 18
tests/ContentManage/Services/CP/SyncSubscribeTest.php

@@ -1,18 +0,0 @@
-<?php
-
-namespace Tests\ContentManage\Services\CP;
-
-use Modules\ContentManage\Services\CpManage\SyncSubscribe;
-use PHPUnit\Framework\TestCase;
-
-class SyncSubscribeTest extends \Tests\TestCase
-{
-    public function testsync() {
-        $syncSubscribe = new SyncSubscribe();
-        $syncSubscribe->syncUrl = 'http://pubapi.pre.aizhuishu.com/outapi/zhiyu/getSubsByZhiyu';
-        $syncSubscribe->syncStartDate = '2022-07-25';
-        $syncSubscribe->syncEndDate = '2022-07-26';
-
-        $syncSubscribe->sync();
-    }
-}

+ 0 - 52
tests/ContentManage/Services/CpManage/BookSettlementTest.php

@@ -1,52 +0,0 @@
-<?php
-
-namespace Tests\ContentManage\Services\CpManage;
-
-use Illuminate\Support\Facades\DB;
-use Modules\Common\Support\Trace\TraceContext;
-use Modules\ContentManage\Services\CpManage\BookSettlement;
-use PHPUnit\Framework\TestCase;
-
-class BookSettlementTest extends \Tests\TestCase
-{
-    private $bid = 10002;
-    protected function setUp11(): void
-    {
-        parent::setUp(); // TODO: Change the autogenerated stub
-
-        $startDate = '2023-01-23';
-        $endDate = '2023-05-13';
-
-        $date = $startDate;
-        DB::table('cp_subscribe_statistic_data')
-            ->where(['bid' => $this->bid])
-            ->delete();
-        while ($date <= $endDate) {
-            $nextDate = date_add(date_create($date), date_interval_create_from_date_string('1 day'))->format('Y-m-d');
-            DB::table('cp_subscribe_statistic_data')
-                ->insert([
-                    'bid' => $this->bid,
-                    'calculate_date' => $nextDate,
-                    'settlement_date' => $date,
-                    'month' => date_create($date)->format('Y-m'),
-                    'cp_name' => 'kanshu',
-                    'yesterday_available_amount' => rand(1000 , 5000),
-                    'yesterday_final_amount' => rand(100, 500),
-                    'yesterday_total_coins' => rand(10000, 50000),
-                    'book_settlement_type' => array_rand(['share', 'bottomline', 'buyout'])
-                ]);
-            $date = $nextDate;
-        }
-
-    }
-
-    public function testRun()
-    {
-        $bid = 10002;
-        $month = '2023-03';
-        dump($pInfo = app(TraceContext::class)->getTraceInfo());
-        $service = new BookSettlement($bid, $month);
-        $service->traceContext = TraceContext::newFromParent($pInfo);
-        dump($service->detail());
-    }
-}

+ 1 - 1
tests/Feature/ExampleTest.php

@@ -12,7 +12,7 @@ class ExampleTest extends TestCase
      *
      * @return void
      */
-    public function test_the_application_returns_a_successful_response()
+    public function ttest_the_application_returns_a_successful_response()
     {
         $response = $this->get('/');
 

+ 58 - 0
tests/Feature/MiniprogramTest.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace Tests\Feature;
+
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Illuminate\Foundation\Testing\WithFaker;
+use Tests\TestCase;
+
+class MiniprogramTest extends TestCase
+{
+    /**
+     * php artisan test --testsuite=Feature
+     * A basic feature test example.
+     */
+    public function test_example(): void
+    {
+        $response = $this->getJson('/api/manage/miniprogram/allocation/13');
+        //$response = $this->getJson('/api/manage/miniprogram/index');
+
+        echo $response->getContent();
+    }
+
+
+    public function ttest_store(): void
+    {
+        $response = $this->postJson('/api/manage/miniprogram/update/13',[
+            'name'=>'三个十千短剧',
+            'company'=>'三个三集团',
+            'play_name'=>'三个十千短剧',
+            'type'=>1,
+            'appid'=>'wxts5415641fgtjhuswsae13',
+            'appsecret'=>'2f659djhsjsfa256b5523ta1shqa3d313',
+            'status'=>1,
+            'remark'=>''
+        ]);
+
+        $response->dd();
+    }
+
+
+    public function test_allocation(): void
+    {
+        $response = $this->postJson('/api/manage/miniprogram/allocation/13',[
+            'uids'=>'5,6,7'
+        ]);
+
+        $response->dd();
+    }
+
+
+    public function ttest_index(): void
+    {
+        $name = '亿';
+        $response = $this->getJson('/api/manage/miniprogram/index?name='.$name);
+
+        $response->dd();
+    }
+}

+ 0 - 18
tests/Unit/ExampleTest.php

@@ -16,22 +16,4 @@ class ExampleTest extends TestCase
     {
         $this->assertTrue(true);
     }
-
-    public function testmyLog() {
-        myLog('test1111')->info('kkkkk');
-    }
-
-    public function testDate() {
-        $str = 'php artisan ContentManage:SyncCpSubscribeStatisticDataFromZW --startDate=%s --endDate=%s';
-
-        $startDate = '2023-04-01';
-        $newStr = '';
-        foreach (range(1, 32) as $i) {
-            $endDate = date_add(date_create($startDate), date_interval_create_from_date_string('1 day'))->format('Y-m-d');
-//            dump(sprintf($str, $startDate, $endDate));
-            $newStr .= sprintf($str, $startDate, $endDate) . "\r\n";
-            $startDate = $endDate;
-        }
-        dump($newStr);
-    }
 }