first commit
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
* 系统用户相关数据表
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// 系统用户表
|
||||
if (! Schema::hasTable('sys_user')) {
|
||||
Schema::create('sys_user', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('系统用户ID');
|
||||
$table->string('username', 20)->unique()->comment('用户名');
|
||||
$table->string('password', 100)->comment('密码');
|
||||
$table->string('nickname', 20)->default('')->comment('昵称');
|
||||
$table->integer('avatar_id')->nullable()->comment('头像');
|
||||
$table->integer('sex')->default(0)->comment('性别(男、女)');
|
||||
$table->string('bio', 255)->default('')->nullable()->comment('个人简介');
|
||||
$table->string('mobile', 20)->default('')->comment('手机号');
|
||||
$table->string('email', 50)->unique()->comment('邮箱');
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->integer('dept_id')->default(0)->comment('部门ID');
|
||||
$table->string('login_ip', 60)->default('')->comment('最后登录IP');
|
||||
$table->timestamp('login_time')->nullable()->comment('最后登录时间');
|
||||
$table->integer('status')->default(1)->comment('状态(1正常 0停用)');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->comment('系统用户表');
|
||||
});
|
||||
}
|
||||
|
||||
// 系统用户角色表
|
||||
if (! Schema::hasTable('sys_role')) {
|
||||
Schema::create('sys_role', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('角色ID');
|
||||
$table->string('name', 20)->default('')->comment('角色名称');
|
||||
$table->integer('sort')->default(0)->comment('排序');
|
||||
$table->string('description', 100)->default('')->comment('角色描述');
|
||||
$table->integer('status')->default(1)->comment('状态(1正常 0停用)');
|
||||
$table->timestamps();
|
||||
$table->comment('系统用户角色表');
|
||||
});
|
||||
}
|
||||
|
||||
// 系统用户角色中间表
|
||||
if (! Schema::hasTable('sys_user_role')) {
|
||||
Schema::create('sys_user_role', function (Blueprint $table) {
|
||||
$table->integer('user_id')->comment('用户ID');
|
||||
$table->integer('role_id')->comment('角色ID');
|
||||
$table->unique(['user_id', 'role_id'], 'user_role_unique');
|
||||
$table->comment('系统用户角色关联表');
|
||||
});
|
||||
}
|
||||
|
||||
// 系统用户部门表
|
||||
if (! Schema::hasTable('sys_dept')) {
|
||||
Schema::create('sys_dept', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('部门ID');
|
||||
$table->integer('parent_id')->default(0)->comment('父级ID');
|
||||
$table->string('name', 100)->default('')->comment('部门名称');
|
||||
$table->string('code', 100)->unique()->default('')->comment('部门编码');
|
||||
$table->tinyInteger('type')->default(0)->comment('部门类型 0:公司 1:部门 2:岗位');
|
||||
$table->integer('sort')->default(0)->comment('排序');
|
||||
$table->string('phone', '20')->default('')->nullable()->comment('部门电话');
|
||||
$table->string('email', '50')->default('')->nullable()->comment('部门邮箱');
|
||||
$table->string('address', '255')->default('')->nullable()->comment('部门地址');
|
||||
$table->string('remark', '255')->default('')->nullable()->comment('备注');
|
||||
$table->integer('status')->default(0)->comment('部门状态(0正常 1停用)');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->comment('系统用户部门表');
|
||||
});
|
||||
}
|
||||
|
||||
// 系统用户权限表
|
||||
if (! Schema::hasTable('sys_rule')) {
|
||||
Schema::create('sys_rule', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('权限ID');
|
||||
$table->integer('parent_id')->default(0)->comment('父级ID');
|
||||
$table->string('type', 20)->comment("类型:'menu' | 'route' | 'rule'");
|
||||
$table->string('key', 100)->unique()->comment('唯一标识');
|
||||
$table->string('name', 100)->comment('名称');
|
||||
$table->string('path', 100)->nullable()->comment('路径');
|
||||
$table->string('icon', 100)->nullable()->comment('图标');
|
||||
$table->integer('order')->default(0)->comment('排序');
|
||||
$table->string('local', 100)->nullable()->comment('语言包');
|
||||
$table->integer('status')->default(1)->comment('状态:1、正常,0、禁用');
|
||||
$table->integer('hidden')->default(1)->comment('显示:1、显示,0、隐藏');
|
||||
$table->integer('link')->default(0)->comment('是否外链:1、是,0、否');
|
||||
$table->timestamps();
|
||||
$table->comment('系统用户权限表');
|
||||
});
|
||||
}
|
||||
|
||||
// 角色权限关联表
|
||||
if (! Schema::hasTable('sys_role_rule')) {
|
||||
Schema::create('sys_role_rule', function (Blueprint $table) {
|
||||
$table->integer('role_id')->comment('角色ID');
|
||||
$table->integer('rule_id')->comment('权限ID');
|
||||
$table->primary(['role_id', 'rule_id'], 'role_rule_primary');
|
||||
$table->comment('角色权限关联表');
|
||||
});
|
||||
}
|
||||
|
||||
// 登录日志表
|
||||
if (! Schema::hasTable('sys_login_record')) {
|
||||
Schema::create('sys_login_record', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('记录ID');
|
||||
$table->string('username', 20)->default('')->comment('用户名');
|
||||
$table->integer('user_id')->comment('用户ID');
|
||||
$table->string('ipaddr', 60)->default('')->comment('登录IP');
|
||||
$table->string('login_location', 255)->default('')->comment('登录地点');
|
||||
$table->string('browser', 255)->default('')->comment('浏览器');
|
||||
$table->string('os', 255)->default('')->comment('操作系统');
|
||||
$table->string('status', 1)->default('0')->comment('登录状态(0成功 1失败)');
|
||||
$table->string('msg', 255)->default('')->comment('提示消息');
|
||||
$table->timestamp('login_time')->comment('登录时间');
|
||||
$table->comment('系统用户登录日志表');
|
||||
});
|
||||
}
|
||||
|
||||
// token 表
|
||||
if (! Schema::hasTable('sys_access_token')) {
|
||||
Schema::create('sys_access_token', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->comment('token table');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sys_user');
|
||||
Schema::dropIfExists('sys_rule');
|
||||
Schema::dropIfExists('sys_dept');
|
||||
Schema::dropIfExists('sys_role');
|
||||
Schema::dropIfExists('sys_user_role');
|
||||
Schema::dropIfExists('sys_role_rule');
|
||||
Schema::dropIfExists('sys_login_record');
|
||||
Schema::dropIfExists('sys_access_token');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
* 字典数据表
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('sys_dict')) {
|
||||
Schema::create('sys_dict', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name', 100)->comment('字典名称');
|
||||
$table->string('code', 100)->unique()->comment('字典编码');
|
||||
$table->string('describe', 500)->nullable()->comment('字典描述');
|
||||
$table->unsignedTinyInteger('status')->default(0)->comment('状态:0正常 1停用');
|
||||
$table->unsignedInteger('sort')->default(0)->comment('排序');
|
||||
$table->timestamps();
|
||||
$table->comment('字典类型表');
|
||||
});
|
||||
}
|
||||
if (! Schema::hasTable('sys_dict_item')) {
|
||||
Schema::create('sys_dict_item', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedBigInteger('dict_id')->comment('字典ID');
|
||||
$table->string('label', 100)->comment('字典标签');
|
||||
$table->string('value', 100)->comment('字典键值');
|
||||
$table->string('color', 50)->default('default')->comment('颜色');
|
||||
$table->unsignedTinyInteger('status')->default(0)->comment('状态:0正常 1停用');
|
||||
$table->unsignedInteger('sort')->default(0)->comment('排序');
|
||||
$table->timestamps();
|
||||
$table->index('dict_id');
|
||||
$table->comment('字典数据表');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sys_dict');
|
||||
Schema::dropIfExists('sys_dict_item');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
* 文件数据表
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('sys_file')) {
|
||||
Schema::create('sys_file', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('文件ID');
|
||||
$table->integer('group_id')->default(0)->comment('文件分组ID');
|
||||
$table->integer('channel')->default(10)->comment('上传来源(10:系统用户 20:App用户端)');
|
||||
$table->string('disk', 10)->comment('存储方式');
|
||||
$table->integer('file_type')->comment('文件类型');
|
||||
$table->string('file_name', 255)->comment('文件名称');
|
||||
$table->string('file_path', 255)->comment('文件路径');
|
||||
$table->integer('file_size')->comment('文件大小(字节)');
|
||||
$table->string('file_ext', 20)->comment('文件扩展名');
|
||||
$table->integer('uploader_id')->comment('上传者用户ID');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
$table->comment('文件表');
|
||||
});
|
||||
}
|
||||
if (! Schema::hasTable('sys_file_group')) {
|
||||
Schema::create('sys_file_group', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('文件分组ID');
|
||||
$table->integer('parent_id')->default(0)->comment('上级ID');
|
||||
$table->string('name', 50)->comment('文件名称');
|
||||
$table->integer('sort')->comment('分组排序');
|
||||
$table->string('describe', 500)->nullable()->comment('分组描述');
|
||||
$table->timestamps();
|
||||
$table->comment('文件分组表');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sys_file');
|
||||
Schema::dropIfExists('sys_file_group');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('sys_site_config_items')) {
|
||||
Schema::create('sys_site_config_items', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('key', 50)->comment('设置项标示');
|
||||
$table->string('title', 50)->comment('设置标题');
|
||||
$table->string('describe', 500)->nullable()->default('')->comment('设置项描述');
|
||||
$table->string('values', 255)->nullable()->default('')->comment('设置值');
|
||||
$table->string('type', 50)->comment('设置类型');
|
||||
$table->string('options', 500)->nullable()->comment('options配置');
|
||||
$table->string('props', 500)->nullable()->comment('props配置');
|
||||
$table->integer('group_id')->comment('分组ID');
|
||||
$table->integer('sort')->comment('排序');
|
||||
$table->timestamps();
|
||||
$table->comment('系统设置表');
|
||||
$table->unique(['key', 'group_id']);
|
||||
});
|
||||
}
|
||||
if (! Schema::hasTable('sys_site_config_group')) {
|
||||
Schema::create('sys_site_config_group', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('title', 50)->comment('分组标题');
|
||||
$table->string('key', 50)->comment('分组KEY');
|
||||
$table->string('remark', 255)->nullable()->comment('备注描述');
|
||||
$table->timestamps();
|
||||
$table->comment('设置分组表');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sys_site_config_items');
|
||||
Schema::dropIfExists('sys_site_config_group');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('user')) {
|
||||
Schema::create('user', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('用户ID');
|
||||
$table->string('username', 20)->unique()->comment('用户名');
|
||||
$table->string('password', 100)->comment('密码');
|
||||
$table->string('nickname', 20)->default('')->comment('昵称');
|
||||
$table->string('email', 50)->default('')->comment('邮箱');
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
$table->comment('APP用户表');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('sys_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('sys_job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sys_failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sys_jobs');
|
||||
Schema::dropIfExists('sys_job_batches');
|
||||
Schema::dropIfExists('sys_failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('sys_app_settings')) {
|
||||
Schema::create('sys_app_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique()->index()->comment('配置键(点号表示法)');
|
||||
$table->tinyInteger('type')->index()->comment('类型枚举:10=String 15=Bool 20=Number 30=Array 40=Object 50=EncryptedString');
|
||||
$table->integer('n')->nullable()->comment('数字/布尔值');
|
||||
$table->string('s')->nullable()->comment('字符串值');
|
||||
$table->text('e')->nullable()->comment('扩展值:JSON/序列化/加密');
|
||||
$table->text('description')->nullable()->comment('描述');
|
||||
$table->timestamps();
|
||||
$table->comment('应用配置表(el-settings 风格列式类型存储)');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sys_app_settings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
if(! Schema::hasTable('agents')){
|
||||
Schema::create('agents', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('namespace', 500)->unique()->comment('完整类命名空间');
|
||||
$table->string('icon', 100)->nullable()->comment('图标');
|
||||
$table->string('name', 100)->comment('显示名称');
|
||||
$table->text('description')->nullable()->comment('描述');
|
||||
$table->json('tags')->nullable()->comment('标签');
|
||||
$table->boolean('enabled')->default(true)->comment('是否启用');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('agent_conversations')) {
|
||||
Schema::create('agent_conversations', function (Blueprint $table) {
|
||||
$table->string('id', 36)->primary();
|
||||
$table->foreignId('user_id')->nullable();
|
||||
$table->string('title');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['user_id', 'updated_at']);
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('agent_conversation_messages')) {
|
||||
Schema::create('agent_conversation_messages', function (Blueprint $table) {
|
||||
$table->string('id', 36)->primary();
|
||||
$table->string('conversation_id', 36)->index();
|
||||
$table->foreignId('user_id')->nullable();
|
||||
$table->string('agent');
|
||||
$table->string('role', 25);
|
||||
$table->text('content');
|
||||
$table->text('attachments');
|
||||
$table->text('tool_calls');
|
||||
$table->text('tool_results');
|
||||
$table->text('usage');
|
||||
$table->text('meta');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['conversation_id', 'user_id', 'updated_at'], 'conversation_index');
|
||||
$table->index(['user_id']);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('agents');
|
||||
Schema::dropIfExists('agent_conversations');
|
||||
Schema::dropIfExists('agent_conversation_messages');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// 首页轮播图表
|
||||
if (! Schema::hasTable('sys_carousel')) {
|
||||
Schema::create('sys_carousel', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('title', 100)->comment('轮播图标题');
|
||||
$table->integer('image_id')->comment('轮播图图片信息(JSON)');
|
||||
$table->string('link', 500)->nullable()->default('')->comment('跳转链接');
|
||||
$table->unsignedTinyInteger('status')->default(0)->comment('状态:0=启用,1=禁用');
|
||||
$table->integer('sort')->default(0)->comment('排序(数字越大越靠前)');
|
||||
$table->timestamps();
|
||||
$table->comment('首页轮播图管理表');
|
||||
});
|
||||
}
|
||||
|
||||
// 首页宫格导航表
|
||||
if (! Schema::hasTable('sys_grid_nav')) {
|
||||
Schema::create('sys_grid_nav', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('title', 100)->comment('导航标题');
|
||||
$table->integer('image_id')->comment('导航图标信息(JSON)');
|
||||
$table->string('link', 500)->nullable()->default('')->comment('跳转链接');
|
||||
$table->unsignedTinyInteger('status')->default(0)->comment('状态:0=启用,1=禁用');
|
||||
$table->integer('sort')->default(0)->comment('排序(数字越大越靠前)');
|
||||
$table->timestamps();
|
||||
$table->comment('首页宫格导航管理表');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sys_carousel');
|
||||
Schema::dropIfExists('sys_grid_nav');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
SysUserSeeder::class,
|
||||
SysDataSeeder::class,
|
||||
SysAgentSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\SystemAgent\Models\AgentModel;
|
||||
|
||||
class SysAgentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$agents = [
|
||||
[
|
||||
'namespace' => 'Modules\SystemAgent\Ai\Agents\XinChatAgent',
|
||||
'name' => 'Xin Chat',
|
||||
'icon' => 'https://file.xinadmin.cn/file/favicons.ico',
|
||||
'description' => 'XinAdmin 默认 AI 助手,支持多轮对话和上下文记忆。',
|
||||
'tags' => ['XinChat', '智能对话'],
|
||||
'enabled' => true,
|
||||
],
|
||||
[
|
||||
'namespace' => 'Modules\SystemTool\Ai\Agents\TestAgent',
|
||||
'name' => 'Test Chat',
|
||||
'icon' => 'https://file.xinadmin.cn/file/favicons.ico',
|
||||
'description' => '测试智能体,用于开发调试。',
|
||||
'enabled' => false,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($agents as $agent) {
|
||||
AgentModel::firstOrCreate(
|
||||
['namespace' => $agent['namespace']],
|
||||
$agent
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class SysDataSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$date = date('Y-m-d H:i:s');
|
||||
// 系统设置初始数据
|
||||
DB::table('sys_site_config_group')->insert([
|
||||
['id' => 1, 'title' => '网站设置', 'key' => 'web', 'remark' => '网站基础设置', 'created_at' => $date, 'updated_at' => $date]
|
||||
]);
|
||||
DB::table('sys_site_config_items')->insert([
|
||||
['id' => 1, 'group_id' => 1, 'key' => 'title', 'title' => '网站标题', 'describe' => '网站标题,用于展示在网站logo旁边和登录页面以及网页title中', 'values' => 'Xin Admin', 'type' => 'Input','options' => "", 'sort' => 0, 'created_at' => $date, 'updated_at' => $date,],
|
||||
['id' => 2, 'group_id' => 1, 'key' => 'logo', 'title' => '网站LOGO', 'describe' => '网站的LOGO,用于标识网站', 'values' => 'https://file.xinadmin.cn/file/favicons.ico', 'type' => 'Input','options' => "", 'sort' => 1, 'created_at' => $date, 'updated_at' => $date,],
|
||||
['id' => 3, 'group_id' => 1, 'key' => 'subtitle', 'title' => '网站副标题', 'describe' => '网站副标题,展示在登录页面标题的下面', 'values' => 'Xin Admin 快速开发框架', 'type' => 'Input','options' => "", 'sort' => 2, 'created_at' => $date, 'updated_at' => $date,],
|
||||
['id' => 4, 'group_id' => 1, 'key' => 'describe', 'title' => '网站描述', 'describe' => '网站的基本描述', 'values' => '没有描述', 'type' => 'TextArea','options' => "", 'sort' => 2, 'created_at' => $date, 'updated_at' => $date,],
|
||||
]);
|
||||
// 字典类型初始数据
|
||||
DB::table('sys_dict')->insert([
|
||||
['id' => 1, 'name' => '用户性别', 'code' => 'sys_user_sex', 'describe' => '用户性别字典', 'status' => 0, 'sort' => 1, 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 2, 'name' => '菜单状态', 'code' => 'sys_show_hide', 'describe' => '菜单状态字典', 'status' => 0, 'sort' => 2, 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 3, 'name' => '系统开关', 'code' => 'sys_normal_disable', 'describe' => '系统开关字典', 'status' => 0, 'sort' => 3, 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 4, 'name' => '权限类型', 'code' => 'sys_rule_type', 'describe' => '系统权限类型字典', 'status' => 0, 'sort' => 4, 'created_at' => $date, 'updated_at' => $date],
|
||||
]);
|
||||
// 字典数据初始数据
|
||||
DB::table('sys_dict_item')->insert([
|
||||
// 用户性别
|
||||
['id' => 1, 'dict_id' => 1, 'label' => '男', 'value' => '0', 'color' => 'blue', 'status' => 0, 'sort' => 1, 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 2, 'dict_id' => 1, 'label' => '女', 'value' => '1', 'color' => 'magenta', 'status' => 0, 'sort' => 2, 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 3, 'dict_id' => 1, 'label' => '未知', 'value' => '2', 'color' => 'default', 'status' => 0, 'sort' => 3, 'created_at' => $date, 'updated_at' => $date],
|
||||
// 菜单状态
|
||||
['id' => 4, 'dict_id' => 2, 'label' => '显示', 'value' => '0', 'color' => 'green', 'status' => 0, 'sort' => 1, 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 5, 'dict_id' => 2, 'label' => '隐藏', 'value' => '1', 'color' => 'red', 'status' => 0, 'sort' => 2, 'created_at' => $date, 'updated_at' => $date],
|
||||
// 系统开关
|
||||
['id' => 6, 'dict_id' => 3, 'label' => '正常', 'value' => '0', 'color' => 'green', 'status' => 0, 'sort' => 1, 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 7, 'dict_id' => 3, 'label' => '停用', 'value' => '1', 'color' => 'red', 'status' => 0, 'sort' => 2, 'created_at' => $date, 'updated_at' => $date],
|
||||
// 权限类型
|
||||
['id' => 8, 'dict_id' => 4, 'label' => '路由', 'value' => 'route', 'color' => 'blue', 'status' => 0, 'sort' => 1, 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 9, 'dict_id' => 4, 'label' => '菜单项', 'value' => 'menu', 'color' => 'green', 'status' => 0, 'sort' => 2, 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 10, 'dict_id' => 4, 'label' => '权限', 'value' => 'rule', 'color' => 'orange', 'status' => 0, 'sort' => 3, 'created_at' => $date, 'updated_at' => $date],
|
||||
]);
|
||||
// 文件初始化数据
|
||||
DB::table('sys_file_group')->insert([
|
||||
['id' => 1, 'name' => '默认分组', 'sort' => 0, 'describe' => '默认分组', 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 2, 'name' => '用户头像', 'sort' => 1, 'describe' => '用户头像分组', 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 3, 'name' => '系统图片', 'sort' => 2, 'describe' => '系统图片分组', 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 4, 'name' => '用户上传', 'sort' => 3, 'describe' => '用户上传分组', 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 5, 'name' => '系统附件', 'sort' => 4, 'describe' => '系统附件分组', 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 6, 'name' => '其他文件', 'sort' => 5, 'describe' => '其他文件分组', 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 7, 'name' => '临时文件', 'sort' => 6, 'describe' => '临时文件分组,用于存放临时上传的文件', 'created_at' => $date, 'updated_at' => $date],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,672 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SysUserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$date = date('Y-m-d H:i:s');
|
||||
DB::table('sys_user')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'username' => 'admin',
|
||||
'nickname' => '管理员',
|
||||
'email' => Str::random(10).'@example.com',
|
||||
'password' => Hash::make('123456'),
|
||||
'dept_id' => 1,
|
||||
'avatar_id' => 1,
|
||||
'email_verified_at' => now(),
|
||||
'remember_token' => Str::random(10),
|
||||
'created_at' => $date,
|
||||
'updated_at' => $date,
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'username' => 'user',
|
||||
'nickname' => '财务',
|
||||
'email' => Str::random(10).'@example.com',
|
||||
'password' => Hash::make('123456'),
|
||||
'dept_id' => 2,
|
||||
'avatar_id' => 1,
|
||||
'email_verified_at' => now(),
|
||||
'remember_token' => Str::random(10),
|
||||
'created_at' => $date,
|
||||
'updated_at' => $date,
|
||||
]
|
||||
]);
|
||||
DB::table('sys_role')->insert([
|
||||
['id' => 1, 'name' => '超级管理员', 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 2, 'name' => '财务', 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 3, 'name' => '电商总监', 'created_at' => $date, 'updated_at' => $date],
|
||||
['id' => 4, 'name' => '市场运营', 'created_at' => $date, 'updated_at' => $date],
|
||||
]);
|
||||
DB::table('sys_dept')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => '新时代股份有限公司',
|
||||
'code' => 'A01',
|
||||
'type' => 0,
|
||||
'parent_id' => 0,
|
||||
'sort' => 0,
|
||||
'phone' => '19999999999',
|
||||
'email' => Str::random(10).'@example.com',
|
||||
'address' => '北京市海淀区某某街道103号',
|
||||
'remark' => '总公司',
|
||||
'created_at' => $date,
|
||||
'updated_at' => $date
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => '新时代软件技术(洛阳)有限公司',
|
||||
'code' => 'A01-B01',
|
||||
'type' => 0,
|
||||
'parent_id' => 1,
|
||||
'sort' => 0,
|
||||
'phone' => '19999999999',
|
||||
'email' => Str::random(10).'@example.com',
|
||||
'address' => '河南省洛阳市龙门区某某街道99号',
|
||||
'remark' => '洛阳市分公司',
|
||||
'created_at' => $date,
|
||||
'updated_at' => $date
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => '新时代智能科技(郑州)有限公司',
|
||||
'code' => 'A01-B02',
|
||||
'type' => 0,
|
||||
'parent_id' => 1,
|
||||
'sort' => 0,
|
||||
'phone' => '19999999999',
|
||||
'email' => Str::random(10).'@example.com',
|
||||
'address' => '河南省郑州市二七区某某街道69号',
|
||||
'remark' => '郑州市分公司',
|
||||
'created_at' => $date,
|
||||
'updated_at' => $date
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'name' => '新征程科技(南阳)有限公司',
|
||||
'code' => 'A01-B03',
|
||||
'type' => 0,
|
||||
'parent_id' => 1,
|
||||
'sort' => 2,
|
||||
'phone' => '19999999999',
|
||||
'email' => Str::random(10).'@example.com',
|
||||
'address' => '河南省南阳市卧龙区某某街道77号',
|
||||
'remark' => '南阳市分公司',
|
||||
'created_at' => $date,
|
||||
'updated_at' => $date
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'name' => '新时代投资发展有限公司',
|
||||
'code' => 'B01',
|
||||
'type' => 0,
|
||||
'parent_id' => 0,
|
||||
'sort' => 2,
|
||||
'phone' => '19999999999',
|
||||
'email' => Str::random(10).'@example.com',
|
||||
'address' => '北京市海淀区人民路666号',
|
||||
'remark' => '我们坚信,卓越的投资在于发现价值,而卓越的投资管理在于创造价值。我们立志成为科技创业者身边最懂业务、最能赋能、最长情的资本伙伴,共同将创新的火种,转化为引领行业的参天大树。',
|
||||
'created_at' => $date,
|
||||
'updated_at' => $date
|
||||
],
|
||||
]);
|
||||
|
||||
$rules = [
|
||||
// [
|
||||
// 'type' => 'menu',
|
||||
// 'name' => '仪表盘',
|
||||
// 'key' => 'dashboard',
|
||||
// 'icon' => 'PieChartOutlined',
|
||||
// 'local' => 'menu.dashboard',
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '分析页',
|
||||
// 'local' => "menu.analysis",
|
||||
// 'key' => 'dashboard.analysis',
|
||||
// 'path' => '/dashboard/analysis',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '监控页',
|
||||
// 'local' => "menu.monitor",
|
||||
// 'key' => 'dashboard.monitor',
|
||||
// 'path' => '/dashboard/monitor',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '工作台',
|
||||
// 'local' => "menu.workplace",
|
||||
// 'key' => 'dashboard.workplace',
|
||||
// 'path' => '/dashboard/workplace',
|
||||
// ]
|
||||
// ]
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'menu',
|
||||
// 'name' => '结果页面',
|
||||
// 'key' => 'result',
|
||||
// 'icon' => 'CheckCircleOutlined',
|
||||
// 'local' => 'menu.result',
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '成功页',
|
||||
// 'local' => "menu.result.success",
|
||||
// 'key' => 'result.success',
|
||||
// 'path' => '/result/success',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '失败页',
|
||||
// 'local' => "menu.result.fail",
|
||||
// 'key' => 'result.fail',
|
||||
// 'path' => '/result/fail',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '警告页',
|
||||
// 'local' => "menu.result.warning",
|
||||
// 'key' => 'result.warning',
|
||||
// 'path' => '/result/warning',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '信息页',
|
||||
// 'local' => "menu.result.info",
|
||||
// 'key' => 'result.info',
|
||||
// 'path' => '/result/info',
|
||||
// ]
|
||||
// ]
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'menu',
|
||||
// 'name' => '异常页面',
|
||||
// 'key' => 'exception',
|
||||
// 'icon' => 'AlertOutlined',
|
||||
// 'local' => 'menu.exception',
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '403',
|
||||
// 'local' => "menu.exception.403",
|
||||
// 'key' => 'exception.403',
|
||||
// 'path' => '/exception/403',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '404',
|
||||
// 'local' => "menu.exception.404",
|
||||
// 'key' => 'exception.404',
|
||||
// 'path' => '/exception/404',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '500',
|
||||
// 'local' => "menu.exception.500",
|
||||
// 'key' => 'exception.500',
|
||||
// 'path' => '/exception/500',
|
||||
// ]
|
||||
// ]
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'menu',
|
||||
// 'name' => '多级菜单',
|
||||
// 'key' => 'multi-menu',
|
||||
// 'local' => "menu.multi-menu",
|
||||
// 'icon' => "MenuOutlined",
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '二级页面',
|
||||
// 'local' => "menu.multi-menu.first",
|
||||
// 'key' => 'multi-menu.first',
|
||||
// 'path' => '/multi-menu/first',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'menu',
|
||||
// 'name' => '二级菜单',
|
||||
// 'local' => "menu.multi-menu.two",
|
||||
// 'key' => 'multi-menu.two',
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '三级页面',
|
||||
// 'local' => "menu.multi-menu.two.second",
|
||||
// 'key' => 'multi-menu.two.second',
|
||||
// 'path' => '/multi-menu/second',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'menu',
|
||||
// 'name' => '三级菜单',
|
||||
// 'local' => "menu.multi-menu.two.three",
|
||||
// 'key' => 'multi-menu.two.three',
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '四级页面',
|
||||
// 'local' => "menu.multi-menu.two.three.third",
|
||||
// 'key' => 'multi-menu.two.three.third',
|
||||
// 'path' => '/multi-menu/third',
|
||||
// ]
|
||||
// ]
|
||||
// ]
|
||||
// ]
|
||||
// ],
|
||||
// ]
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'menu',
|
||||
// 'name' => '页面布局',
|
||||
// 'local' => "menu.page-layout",
|
||||
// 'icon' => "LayoutOutlined",
|
||||
// 'key' => 'page-layout',
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '基础布局',
|
||||
// 'local' => "menu.page-layout.base-layout",
|
||||
// 'key' => 'page-layout.base-layout',
|
||||
// 'path' => '/page-layout/base-layout',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '固定头部',
|
||||
// 'local' => "menu.page-layout.fix-header",
|
||||
// 'key' => 'page-layout.fix-header',
|
||||
// 'path' => '/page-layout/fix-header',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => '页面描述',
|
||||
// 'local' => "menu.page-layout.descriptions",
|
||||
// 'key' => 'page-layout.descriptions',
|
||||
// 'path' => '/page-layout/descriptions',
|
||||
// ]
|
||||
// ]
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'menu',
|
||||
// 'key' => "example",
|
||||
// 'name' => "组件示例",
|
||||
// 'path' => "",
|
||||
// 'icon' => "AppstoreOutlined",
|
||||
// 'local' => "menu.example",
|
||||
// 'hidden' => 1,
|
||||
// 'link' => 0,
|
||||
// 'children' => [
|
||||
// [
|
||||
// 'type' => "route",
|
||||
// 'key' => "example.user-selector",
|
||||
// 'name' => "用户选择器",
|
||||
// 'path' => "/example/user-selector",
|
||||
// 'local' => "menu.example.user-selector",
|
||||
// 'hidden' => 1,
|
||||
// 'link' => 0
|
||||
// ],
|
||||
// [
|
||||
// 'type' => "route",
|
||||
// 'key' => "example.icon-selector",
|
||||
// 'name' => "图标",
|
||||
// 'path' => "/example/icon-selector",
|
||||
// 'local' => "menu.example.icon-selector",
|
||||
// 'hidden' => 1,
|
||||
// 'link' => 0
|
||||
// ],
|
||||
// [
|
||||
// 'type' => "route",
|
||||
// 'key' => "example.image-uploader",
|
||||
// 'name' => "图片上传器",
|
||||
// 'path' => "/example/image-uploader",
|
||||
// 'local' => "menu.example.image-uploader",
|
||||
// 'hidden' => 1,
|
||||
// 'link' => 0
|
||||
// ],
|
||||
// [
|
||||
// 'type' => "route",
|
||||
// 'key' => "example.xin-form",
|
||||
// 'name' => "XinForm 表单",
|
||||
// 'path' => "/example/xin-form",
|
||||
// 'local' => "menu.example.xin-form",
|
||||
// 'hidden' => 1,
|
||||
// 'link' => 0
|
||||
// ],
|
||||
// [
|
||||
// 'type' => "route",
|
||||
// 'key' => "example.xin-table",
|
||||
// 'name' => "XinTable 表格",
|
||||
// 'path' => "/example/xin-table",
|
||||
// 'local' => "menu.example.xin-table",
|
||||
// 'hidden' => 1,
|
||||
// 'link' => 0
|
||||
// ]
|
||||
// ]
|
||||
// ],
|
||||
[
|
||||
'type' => "route",
|
||||
'name' => "轮播图管理",
|
||||
'local' => "menu.system.carousel",
|
||||
'key' => "system.carousel",
|
||||
'path' => "/system/carousel",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '查询列表', 'key' => 'system.carousel.query'],
|
||||
['type' => 'rule', 'name' => '新增轮播图', 'key' => 'system.carousel.create'],
|
||||
['type' => 'rule', 'name' => '编辑轮播图', 'key' => 'system.carousel.update'],
|
||||
['type' => 'rule', 'name' => '删除轮播图', 'key' => 'system.carousel.delete'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => "route",
|
||||
'name' => "宫格导航管理",
|
||||
'local' => "menu.system.grid-nav",
|
||||
'key' => "system.grid-nav",
|
||||
'path' => "/system/grid-nav",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '查询列表', 'key' => 'system.grid-nav.query'],
|
||||
['type' => 'rule', 'name' => '新增导航', 'key' => 'system.grid-nav.create'],
|
||||
['type' => 'rule', 'name' => '编辑导航', 'key' => 'system.grid-nav.update'],
|
||||
['type' => 'rule', 'name' => '删除导航', 'key' => 'system.grid-nav.delete'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => 'menu',
|
||||
'name' => 'AI',
|
||||
'local' => "menu.ai",
|
||||
'icon' => "OpenAIOutlined",
|
||||
'key' => "ai",
|
||||
'children' => [
|
||||
[
|
||||
'type' => "route",
|
||||
'key' => "ai.chat",
|
||||
'name' => "AI对话",
|
||||
"path" => "/ai/chat",
|
||||
'local' => "menu.ai.chat",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '发送消息', 'key' => 'ai.chat.send'],
|
||||
['type' => 'rule', 'name' => '会话列表', 'key' => 'ai.chat.conversations'],
|
||||
['type' => 'rule', 'name' => '消息列表', 'key' => 'ai.chat.messages'],
|
||||
['type' => 'rule', 'name' => '删除会话', 'key' => 'ai.chat.delete'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => "route",
|
||||
'key' => "ai.conversation",
|
||||
'name' => "会话管理",
|
||||
"path" => "/ai/conversation",
|
||||
'local' => "menu.ai.conversation",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '查询会话列表', 'key' => 'ai.conversation.query'],
|
||||
['type' => 'rule', 'name' => '删除会话', 'key' => 'ai.conversation.delete'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => "route",
|
||||
'key' => "ai.agent",
|
||||
'name' => "Agent 管理",
|
||||
"path" => "/ai/agent",
|
||||
'local' => "menu.ai.agent",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '查询列表', 'key' => 'ai.agent.query'],
|
||||
['type' => 'rule', 'name' => '更新 Agent', 'key' => 'ai.agent.update'],
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => "menu",
|
||||
'name' => "系统管理",
|
||||
'local' => "menu.system",
|
||||
'icon' => "SettingOutlined",
|
||||
'key' => "system",
|
||||
'children' => [
|
||||
[
|
||||
'type' => "route",
|
||||
'key' => "system.user",
|
||||
'name' => "用户管理",
|
||||
'path' => "/system/user",
|
||||
'local' => "menu.system.user",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '查询列表', 'key' => 'system.user.query'],
|
||||
['type' => 'rule', 'name' => '新增用户', 'key' => 'system.user.create'],
|
||||
['type' => 'rule', 'name' => '修改用户', 'key' => 'system.user.update'],
|
||||
['type' => 'rule', 'name' => '删除用户', 'key' => 'system.user.delete'],
|
||||
['type' => 'rule', 'name' => '重置用户密码', 'key' => 'system.user.resetPassword'],
|
||||
['type' => 'rule', 'name' => '获取角色选项', 'key' => 'system.user.role'],
|
||||
['type' => 'rule', 'name' => '获取部门选项', 'key' => 'system.user.dept'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => "route",
|
||||
'key' => "system.dept",
|
||||
'name' => "部门管理",
|
||||
'path' => "/system/dept",
|
||||
'local' => "menu.system.dept",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '获取部门列表', 'key' => 'system.dept.query'],
|
||||
['type' => 'rule', 'name' => '新建部门', 'key' => 'system.dept.create'],
|
||||
['type' => 'rule', 'name' => '更新部门信息', 'key' => 'system.dept.update'],
|
||||
['type' => 'rule', 'name' => '删除部门', 'key' => 'system.dept.delete'],
|
||||
['type' => 'rule', 'name' => '获取部门用户', 'key' => 'system.dept.users'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => "route",
|
||||
'key' => "system.role",
|
||||
'name' => "角色管理",
|
||||
'path' => "/system/role",
|
||||
'local' => "menu.system.role",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '新增角色', 'key' => 'system.role.create'],
|
||||
['type' => 'rule', 'name' => '查询角色列表', 'key' => 'system.role.query'],
|
||||
['type' => 'rule', 'name' => '更新角色信息', 'key' => 'system.role.update'],
|
||||
['type' => 'rule', 'name' => '删除角色', 'key' => 'system.role.delete'],
|
||||
['type' => 'rule', 'name' => '设置启用状态', 'key' => 'system.role.status'],
|
||||
['type' => 'rule', 'name' => '获取角色用户', 'key' => 'system.role.users'],
|
||||
['type' => 'rule', 'name' => '设置角色权限', 'key' => 'system.role.setRule'],
|
||||
['type' => 'rule', 'name' => '获取权限选项', 'key' => 'system.role.ruleList'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => "route",
|
||||
'key' => "system.rule",
|
||||
'name' => "菜单管理",
|
||||
'path' => "/system/rule",
|
||||
'local' => "menu.system.rule",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '获取权限列表', 'key' => 'system.rule.query'],
|
||||
['type' => 'rule', 'name' => '创建权限规则', 'key' => 'system.rule.create'],
|
||||
['type' => 'rule', 'name' => '更新权限规则', 'key' => 'system.rule.update'],
|
||||
['type' => 'rule', 'name' => '删除权限规则', 'key' => 'system.rule.delete'],
|
||||
['type' => 'rule', 'name' => '获取父级权限', 'key' => 'system.rule.parentQuery'],
|
||||
['type' => 'rule', 'name' => '设置显示状态', 'key' => 'system.rule.show'],
|
||||
['type' => 'rule', 'name' => '设置启用状态', 'key' => 'system.rule.status'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => "route",
|
||||
'name' => "文件管理",
|
||||
'local' => "menu.system.file",
|
||||
'key' => "system.file",
|
||||
'path' => "/system/file",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '获取文件夹', 'key' => 'system.file.group.query'],
|
||||
['type' => 'rule', 'name' => '新增文件夹', 'key' => 'system.file.group.create'],
|
||||
['type' => 'rule', 'name' => '编辑文件夹', 'key' => 'system.file.group.update'],
|
||||
['type' => 'rule', 'name' => '删除文件夹', 'key' => 'system.file.group.delete'],
|
||||
['type' => 'rule', 'name' => '查询文件列表', 'key' => 'system.file.list.query'],
|
||||
['type' => 'rule', 'name' => '上传文件', 'key' => 'system.file.list.upload'],
|
||||
['type' => 'rule', 'name' => '下载文件', 'key' => 'system.file.list.download'],
|
||||
['type' => 'rule', 'name' => '删除文件', 'key' => 'system.file.list.delete'],
|
||||
['type' => 'rule', 'name' => '永久删除文件', 'key' => 'system.file.list.force-delete'],
|
||||
['type' => 'rule', 'name' => '恢复文件', 'key' => 'system.file.list.restore'],
|
||||
['type' => 'rule', 'name' => '查看回收站', 'key' => 'system.file.list.trashed'],
|
||||
['type' => 'rule', 'name' => '清空回收站', 'key' => 'system.file.list.clean-trashed'],
|
||||
['type' => 'rule', 'name' => '复制文件', 'key' => 'system.file.list.copy'],
|
||||
['type' => 'rule', 'name' => '移动文件', 'key' => 'system.file.list.move'],
|
||||
['type' => 'rule', 'name' => '重命名文件', 'key' => 'system.file.list.rename']
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => "route",
|
||||
'name' => "系统字典",
|
||||
'local' => "menu.system.dict",
|
||||
'key' => "system.dict",
|
||||
'path' => "/system/dict",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '字典列表', 'key' => 'system.dict.list.query'],
|
||||
['type' => 'rule', 'name' => '新增字典', 'key' => 'system.dict.list.create'],
|
||||
['type' => 'rule', 'name' => '删除字典', 'key' => 'system.dict.list.delete'],
|
||||
['type' => 'rule', 'name' => '更新字典', 'key' => 'system.dict.list.update'],
|
||||
['type' => 'rule', 'name' => '字典项列表', 'key' => 'system.dict.item.query'],
|
||||
['type' => 'rule', 'name' => '字典项新增', 'key' => 'system.dict.item.create'],
|
||||
['type' => 'rule', 'name' => '字典项编辑', 'key' => 'system.dict.item.update'],
|
||||
['type' => 'rule', 'name' => '字典项删除', 'key' => 'system.dict.item.delete'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => "route",
|
||||
'name' => "系统配置",
|
||||
'local' => "menu.system.config",
|
||||
'key' => "system.config",
|
||||
'path' => "/system/config",
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '配置列表', 'key' => 'system.config.items.query'],
|
||||
['type' => 'rule', 'name' => '新增配置', 'key' => 'system.config.items.create'],
|
||||
['type' => 'rule', 'name' => '编辑配置', 'key' => 'system.config.items.update'],
|
||||
['type' => 'rule', 'name' => '删除配置', 'key' => 'system.config.items.delete'],
|
||||
['type' => 'rule', 'name' => '保存配置', 'key' => 'system.config.items.save'],
|
||||
['type' => 'rule', 'name' => '刷新配置', 'key' => 'system.config.items.refresh'],
|
||||
['type' => 'rule', 'name' => '配置组编辑', 'key' => 'system.config.group.update'],
|
||||
['type' => 'rule', 'name' => '配置组删除', 'key' => 'system.config.items.item.delete'],
|
||||
['type' => 'rule', 'name' => '配置组列表', 'key' => 'system.config.group.query'],
|
||||
['type' => 'rule', 'name' => '配置组新增', 'key' => 'system.config.group.create'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => 'route',
|
||||
'key' => 'system.mail',
|
||||
'name' => '邮件配置',
|
||||
'path' => '/system/mail',
|
||||
'local' => 'menu.system.mail',
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '获取配置', 'key' => 'system.mail.config'],
|
||||
['type' => 'rule', 'name' => '保存配置', 'key' => 'system.mail.save'],
|
||||
['type' => 'rule', 'name' => '发送测试', 'key' => 'system.mail.test'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => 'route',
|
||||
'key' => 'system.storage',
|
||||
'name' => '存储配置',
|
||||
'path' => '/system/storage',
|
||||
'local' => 'menu.system.storage',
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '获取配置', 'key' => 'system.storage.config'],
|
||||
['type' => 'rule', 'name' => '保存配置', 'key' => 'system.storage.save'],
|
||||
['type' => 'rule', 'name' => '测试连接', 'key' => 'system.storage.test'],
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => 'route',
|
||||
'key' => 'system.ai',
|
||||
'name' => 'AI 配置',
|
||||
'path' => '/system/ai',
|
||||
'local' => 'menu.system.ai',
|
||||
'children' => [
|
||||
['type' => 'rule', 'name' => '获取可用AI列表', 'key' => 'system.ai.list'],
|
||||
['type' => 'rule', 'name' => '获取AI配置', 'key' => 'system.ai.config'],
|
||||
['type' => 'rule', 'name' => '保存AI配置', 'key' => 'system.ai.save'],
|
||||
['type' => 'rule', 'name' => '测试连接', 'key' => 'system.ai.test'],
|
||||
]
|
||||
],
|
||||
// [
|
||||
// 'type' => "route",
|
||||
// 'name' => "系统信息",
|
||||
// 'local' => "menu.system.info",
|
||||
// 'key' => "system.info",
|
||||
// 'path' => "/system/info",
|
||||
// ]
|
||||
]
|
||||
],
|
||||
// [
|
||||
// 'type' => 'route',
|
||||
// 'name' => 'XinAdmin',
|
||||
// 'local' => "menu.xin-admin",
|
||||
// 'key' => "xin-admin",
|
||||
// 'icon' => "LinkOutlined",
|
||||
// 'link' => 1,
|
||||
// 'path' => 'https://xinadmin.cn',
|
||||
// ]
|
||||
];
|
||||
|
||||
$this->insertRules($rules);
|
||||
|
||||
DB::table('sys_role_rule')->insertUsing(
|
||||
['role_id', 'rule_id'],
|
||||
DB::table('sys_rule')
|
||||
->where('status', 1)
|
||||
->select(DB::raw('1 as role_id'), 'id')
|
||||
);
|
||||
|
||||
DB::table('sys_user_role')->insert([
|
||||
[
|
||||
'user_id' => 1,
|
||||
'role_id' => 1,
|
||||
],
|
||||
[
|
||||
'user_id' => 2,
|
||||
'role_id' => 2,
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归插入权限规则数据
|
||||
*
|
||||
* @param array $rules 规则数据
|
||||
* @param int $pid 父级ID,默认为0(顶级)
|
||||
* @return void
|
||||
*/
|
||||
function insertRules(array $rules, int $pid = 0): void
|
||||
{
|
||||
$order = 0;
|
||||
foreach ($rules as $rule) {
|
||||
// 准备插入数据
|
||||
$insertData = [
|
||||
'parent_id' => $pid,
|
||||
'type' => $rule['type'],
|
||||
'key' => $rule['key'],
|
||||
'name' => $rule['name'],
|
||||
'path' => $rule['path'] ?? '',
|
||||
'icon' => $rule['icon'] ?? '',
|
||||
'order' => $order++,
|
||||
'local' => $rule['local'] ?? '',
|
||||
'status' => 1,
|
||||
'hidden' => 1,
|
||||
'link' => $rule['link'] ?? 0,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
|
||||
// 插入数据并获取插入的ID
|
||||
$currentId = DB::table('sys_rule')->insertGetId($insertData);
|
||||
|
||||
// 如果有子菜单,递归插入
|
||||
if (!empty($rule['children']) && is_array($rule['children'])) {
|
||||
$this->insertRules($rule['children'], $currentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user