mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 18:17:49 +08:00
first commit
This commit is contained in:
43
migrations/2025_09_11_174754_create_admin_user_table.php
Normal file
43
migrations/2025_09_11_174754_create_admin_user_table.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Hyperf\Database\Schema\Schema;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hyperf\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('admin_user', function (Blueprint $table) {
|
||||
$table->comment('管理员信息表');
|
||||
$table->bigIncrements('id')->comment('用户ID,主键');
|
||||
$table->string('username', 20)->unique()->comment('用户名')->unique();
|
||||
$table->string('password', 100)->comment('密码');
|
||||
$table->string('user_type', 3)->default('100')->comment('用户类型:100=系统用户');
|
||||
$table->string('nickname', 30)->default('')->comment('用户昵称');
|
||||
$table->string('phone', 11)->default('')->comment('手机');
|
||||
$table->string('email', 50)->default('')->comment('用户邮箱');
|
||||
$table->string('avatar', 255)->default('')->comment('用户头像');
|
||||
$table->string('signed', 255)->default('')->comment('个人签名');
|
||||
$table->tinyInteger('status')->default(1)->comment('状态:1=正常,2=停用');
|
||||
$table->ipAddress('login_ip')->default('127.0.0.1')->comment('最后登陆IP');
|
||||
$table->timestamp('login_time')->useCurrent()->comment('最后登陆时间');
|
||||
$table->json('backend_setting')->nullable()->comment('后台设置数据');
|
||||
$table->unsignedBigInteger('created_by')->default(0)->comment('创建人ID');
|
||||
$table->unsignedBigInteger('updated_by')->default(0)->comment('更新人ID');
|
||||
$table->datetimes();
|
||||
$table->string('remark', 255)->default('')->comment('备注');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('admin_user');
|
||||
}
|
||||
};
|
||||
39
migrations/2025_09_11_175006_create_admin_menu_table.php
Normal file
39
migrations/2025_09_11_175006_create_admin_menu_table.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Hyperf\Database\Schema\Schema;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hyperf\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('admin_menu', function (Blueprint $table) {
|
||||
$table->comment('后台菜单信息表');
|
||||
$table->bigIncrements('id')->comment('主键');
|
||||
$table->bigInteger('parent_id')->unsigned()->comment('父ID');
|
||||
$table->string('name', 50)->default('')->comment('菜单名称')->unique();
|
||||
$table->json('meta')->comment('附加属性')->nullable();
|
||||
$table->string('path', 60)->default('')->comment('路径');
|
||||
$table->string('component', 150)->default('')->comment('组件路径');
|
||||
$table->string('redirect', 100)->comment('重定向地址')->default('');
|
||||
$table->tinyInteger('status')->comment('状态:1=正常,2=停用')->default(1);
|
||||
$table->smallInteger('sort')->comment('排序')->default(0);
|
||||
$table->unsignedBigInteger('created_by')->default(0)->comment('创建人ID');
|
||||
$table->unsignedBigInteger('updated_by')->default(0)->comment('更新人ID');
|
||||
$table->datetimes();
|
||||
$table->string('remark', 60)->comment('备注')->default('');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('admin_menu');
|
||||
}
|
||||
};
|
||||
35
migrations/2025_09_11_175013_create_admin_role_table.php
Normal file
35
migrations/2025_09_11_175013_create_admin_role_table.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Hyperf\Database\Schema\Schema;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hyperf\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('admin_role', function (Blueprint $table) {
|
||||
$table->comment('后台角色信息表');
|
||||
$table->bigIncrements('id')->comment('主键');
|
||||
$table->string('name', 30)->comment('角色名称');
|
||||
$table->string('code', 100)->comment('角色代码')->unique();
|
||||
$table->tinyInteger('status')->comment('状态:1=正常,2=停用')->default(1);
|
||||
$table->smallInteger('sort')->comment('排序')->default(0);
|
||||
$table->unsignedBigInteger('created_by')->default(0)->comment('创建人ID');
|
||||
$table->unsignedBigInteger('updated_by')->default(0)->comment('更新人ID');
|
||||
$table->datetimes();
|
||||
$table->string('remark')->comment('备注')->default('');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('admin_role');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Hyperf\Database\Schema\Schema;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hyperf\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('admin_user_login_log', function (Blueprint $table) {
|
||||
$table->comment('后台登录日志表');
|
||||
$table->bigIncrements('id')->comment('主键');
|
||||
$table->bigInteger('admin_user_id')->comment('用户id');
|
||||
$table->addColumn('string', 'username', ['length' => 20, 'comment' => '用户名']);
|
||||
$table->addColumn('ipAddress', 'ip', ['comment' => '登录IP地址'])->nullable();
|
||||
$table->addColumn('string', 'os', ['length' => 255, 'comment' => '操作系统'])->nullable();
|
||||
$table->addColumn('string', 'browser', ['length' => 255, 'comment' => '浏览器'])->nullable();
|
||||
$table->addColumn('smallInteger', 'status', ['default' => 1, 'comment' => '登录状态 (1成功 2失败)']);
|
||||
$table->addColumn('string', 'message', ['length' => 50, 'comment' => '提示消息'])->nullable();
|
||||
$table->dateTime('login_time')->comment('登录时间');
|
||||
$table->addColumn('string', 'remark', ['length' => 255, 'comment' => '备注'])->nullable();
|
||||
$table->index('username');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('admin_user_login_log');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Hyperf\Database\Schema\Schema;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hyperf\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('admin_user_operation_log', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->comment('后台操作日志表');
|
||||
$table->bigInteger('admin_user_id')->comment('用户id');
|
||||
$table->addColumn('string', 'username', ['length' => 20, 'comment' => '用户名']);
|
||||
$table->addColumn('string', 'method', ['length' => 20, 'comment' => '请求方式']);
|
||||
$table->addColumn('string', 'router', ['length' => 500, 'comment' => '请求路由']);
|
||||
$table->addColumn('string', 'service_name', ['length' => 30, 'comment' => '业务名称']);
|
||||
$table->addColumn('ipAddress', 'ip', ['comment' => '请求IP地址'])->nullable();
|
||||
$table->addColumn('timestamp', 'created_at', ['precision' => 0, 'comment' => '创建时间'])->nullable();
|
||||
$table->addColumn('timestamp', 'updated_at', ['precision' => 0, 'comment' => '更新时间'])->nullable();
|
||||
$table->addColumn('string', 'remark', ['length' => 255, 'comment' => '备注'])->nullable();
|
||||
$table->index('username');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('admin_user_operation_log');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Hyperf\Database\Schema\Schema;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hyperf\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('admin_user_belongs_role', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->bigInteger('admin_user_id')->comment('用户id');
|
||||
$table->bigInteger('admin_role_id')->comment('角色id');
|
||||
$table->datetimes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('admin_user_belongs_role');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Hyperf\Database\Schema\Schema;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hyperf\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('admin_role_belongs_menu', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->bigInteger('admin_role_id')->comment('角色id');
|
||||
$table->bigInteger('admin_menu_id')->comment('菜单id');
|
||||
$table->datetimes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('admin_role_belongs_menu');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user