feat: 创建工厂类和种子数据

- SystemSettingFactory: 系统设置工厂
- TerminalFactory: 终端工厂
- SopTemplateFactory: SOP模板工厂
- SystemSettingSeeder: 系统设置种子数据
- TerminalSeeder: 终端种子数据
- SopTemplateSeeder: SOP模板种子数据
- 更新 DatabaseSeeder 注册新的种子类
This commit is contained in:
2026-03-09 10:07:49 +08:00
parent 9d0055138c
commit ef195d1ea0
7 changed files with 913 additions and 0 deletions

View File

@@ -0,0 +1,104 @@
<?php
namespace Database\Factories;
use App\Models\SystemSetting;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\SystemSetting>
*/
class SystemSettingFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = SystemSetting::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'key' => fake()->unique()->word(),
'value' => [
'enabled' => fake()->boolean(),
'value' => fake()->word(),
],
'group' => fake()->randomElement(['general', 'embedding', 'chunking', 'system']),
'description' => fake()->sentence(),
'is_public' => fake()->boolean(),
];
}
/**
* 指定配置为嵌入模型配置
*/
public function embedding(): static
{
return $this->state(fn (array $attributes) => [
'group' => 'embedding',
'value' => [
'model_name' => fake()->randomElement(['text-embedding-ada-002', 'text-embedding-3-small', 'text-embedding-3-large']),
'api_key' => 'sk-' . fake()->uuid(),
'endpoint_url' => fake()->url(),
'dimensions' => fake()->randomElement([1536, 3072]),
],
]);
}
/**
* 指定配置为分块参数配置
*/
public function chunking(): static
{
return $this->state(fn (array $attributes) => [
'group' => 'chunking',
'value' => [
'chunk_size' => fake()->numberBetween(500, 2000),
'chunk_overlap' => fake()->numberBetween(50, 200),
'separator' => fake()->randomElement(["\n\n", "\n", " "]),
],
]);
}
/**
* 指定配置为系统全局配置
*/
public function system(): static
{
return $this->state(fn (array $attributes) => [
'group' => 'system',
'value' => [
'system_name' => fake()->company(),
'timeout' => fake()->numberBetween(30, 300),
'max_retries' => fake()->numberBetween(1, 5),
],
]);
}
/**
* 指定配置为公开配置
*/
public function public(): static
{
return $this->state(fn (array $attributes) => [
'is_public' => true,
]);
}
/**
* 指定配置为私有配置
*/
public function private(): static
{
return $this->state(fn (array $attributes) => [
'is_public' => false,
]);
}
}