@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\TestData\SupplyDemandTestDataGenerator;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class GenerateSupplyDemandDemo extends Command
|
||||
{
|
||||
protected $signature = 'demo:generate-supply-demand {--count=50} {--users=20}';
|
||||
|
||||
protected $description = '生成供需模块演示数据(含附件、会话、消息、收藏等)';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$count = (int)$this->option('count');
|
||||
$users = (int)$this->option('users');
|
||||
|
||||
$this->info("开始生成:供需 {$count} 条,最少用户 {$users} 个...");
|
||||
$generator = new SupplyDemandTestDataGenerator();
|
||||
$generator->generate($count, $users, function (string $msg) {
|
||||
$this->line($msg);
|
||||
});
|
||||
|
||||
$this->info('生成完成');
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\TestData\CourseContentEvaluationTestDataGenerator;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SeedCourseContentEvaluations extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'seed:course-evaluations
|
||||
{--evaluations=20 : 生成评价问卷数量}
|
||||
{--users=50 : 最少用户数量}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '生成课程内容评价模块的测试数据,包括问卷、问题字段和用户提交数据';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$evaluationCount = (int) $this->option('evaluations');
|
||||
$minUsers = (int) $this->option('users');
|
||||
|
||||
$this->info("开始生成课程内容评价测试数据...");
|
||||
$this->info("计划生成 {$evaluationCount} 个评价问卷,确保至少 {$minUsers} 个用户");
|
||||
|
||||
$generator = new CourseContentEvaluationTestDataGenerator();
|
||||
|
||||
$startTime = microtime(true);
|
||||
|
||||
try {
|
||||
$generator->generate($evaluationCount, $minUsers, function (string $message) {
|
||||
$this->line(" → {$message}");
|
||||
});
|
||||
|
||||
$duration = round(microtime(true) - $startTime, 2);
|
||||
$this->info("✅ 数据生成完成!耗时 {$duration} 秒");
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->error("❌ 数据生成失败:" . $e->getMessage());
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('courses', function (Blueprint $table) {
|
||||
// 过期后链接
|
||||
$table->string('url')->nullable()->comment('过期后链接');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('courses', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Services\TestData\SupplyDemandTestDataGenerator;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SupplyDemandDemoSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$generator = new SupplyDemandTestDataGenerator();
|
||||
$generator->generate(50, 20, function (string $msg) {
|
||||
$this->command?->info($msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 143 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 4.1 KiB |