feat:动态权限
This commit is contained in:
@@ -4,7 +4,8 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@@ -12,6 +13,10 @@ return new class () extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('roles')) {
|
||||
return ;
|
||||
}
|
||||
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('role_name', 30)->comment('角色名称');
|
||||
|
@@ -4,7 +4,8 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@@ -12,6 +13,10 @@ return new class () extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('jobs')) {
|
||||
return ;
|
||||
}
|
||||
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('job_name', 50)->comment('岗位名称');
|
||||
|
@@ -4,7 +4,8 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@@ -12,6 +13,10 @@ return new class () extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('departments')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('departments', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('parent_id')->default(0)->comment('父级ID');
|
||||
|
@@ -1,48 +0,0 @@
|
||||
<?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::create('permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('permission_name', 30)->comment('菜单名称');
|
||||
$table->integer('parent_id')->default('1')->comment('父级菜单');
|
||||
$table->string('route', 50)->comment('路由');
|
||||
$table->string('icon', 50)->comment('菜单 icon');
|
||||
$table->string('module', 50)->comment('所属模块');
|
||||
$table->string('permission_mark')->comment('权限标识');
|
||||
$table->string('component')->comment('组件');
|
||||
$table->string('redirect')->comment('组件跳转');
|
||||
$table->tinyInteger('keepalive')->default('1')->comment('1 缓存 2 不缓存');
|
||||
$table->tinyInteger('type')->default('1')->comment('1 菜单 2 按钮');
|
||||
$table->tinyInteger('hidden')->default('1')->comment('1 显示 2 隐藏');
|
||||
$table->integer('sort')->default('1')->comment('排序');
|
||||
$table->creatorId();
|
||||
$table->createdAt();
|
||||
$table->updatedAt();
|
||||
$table->deletedAt();
|
||||
|
||||
$table->engine = 'InnoDB';
|
||||
$table->comment('权限模块');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('permissions');
|
||||
}
|
||||
};
|
@@ -12,6 +12,10 @@ return new class () extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('permissions')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('parent_id')->default(0)->comment('父级菜单');
|
||||
@@ -19,7 +23,7 @@ return new class () extends Migration {
|
||||
$table->string('route', 50)->comment('前端路由');
|
||||
$table->string('icon', 50)->comment('菜单 icon');
|
||||
$table->string('module', 50)->comment('所属模块');
|
||||
$table->string('permission_mark', 100)->comment('权限标识,使用 @ 分割');
|
||||
$table->string('permission_mark', 100)->default('')->comment('权限标识,使用 @ 分割');
|
||||
$table->string('component')->comment('组件');
|
||||
$table->string('redirect')->nullable()->comment('跳转地址');
|
||||
$table->tinyInteger('keepalive')->default('1')->comment('1 缓存 2 不缓存');
|
||||
|
@@ -0,0 +1,34 @@
|
||||
<?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(): void
|
||||
{
|
||||
Schema::create('user_has_roles', function (Blueprint $table) {
|
||||
$table->integer('user_id')->comment('users primary key');
|
||||
|
||||
$table->integer('role_id')->comment('roles primary key');
|
||||
|
||||
$table->comment('user relate roles');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
};
|
@@ -0,0 +1,34 @@
|
||||
<?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(): void
|
||||
{
|
||||
Schema::create('role_has_permissions', function (Blueprint $table) {
|
||||
$table->integer('role_id')->comment('roles primary key');
|
||||
|
||||
$table->integer('permission_id')->comment('permissions primary key');
|
||||
|
||||
$table->comment('role relate permissions');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
};
|
@@ -0,0 +1,34 @@
|
||||
<?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(): void
|
||||
{
|
||||
Schema::create('user_has_jobs', function (Blueprint $table) {
|
||||
$table->integer('user_id')->comment('users primary key');
|
||||
|
||||
$table->integer('job_id')->comment('jobs primary key');
|
||||
|
||||
$table->comment('user relate jobs');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
};
|
@@ -0,0 +1,34 @@
|
||||
<?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(): void
|
||||
{
|
||||
Schema::create('role_has_departments', function (Blueprint $table) {
|
||||
$table->integer('role_id')->comment('roles primary key');
|
||||
|
||||
$table->integer('department_id')->comment('departments primary key');
|
||||
|
||||
$table->comment('role relate departments');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user