From 26c879b9542bfbe6a431d17f89c475837271283c Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Mon, 29 Apr 2024 10:17:54 +0800 Subject: [PATCH] check --- app/Http/Middleware/CheckUserRole.php | 8 ++++-- ...24_03_27_113404_create_workflows_table.php | 1 + ..._add_apply_at_to_workflow_checks_table.php | 28 ------------------- 3 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 database/migrations/2024_04_28_230319_add_apply_at_to_workflow_checks_table.php diff --git a/app/Http/Middleware/CheckUserRole.php b/app/Http/Middleware/CheckUserRole.php index 7f94574..2bbe58f 100644 --- a/app/Http/Middleware/CheckUserRole.php +++ b/app/Http/Middleware/CheckUserRole.php @@ -18,12 +18,16 @@ class CheckUserRole { $user = auth('api')->user(); $currentRole = $user->userRole(); + $hasPermissions = false; foreach ($currentRole as $role) { $roleValue = $role->value; - if (!in_array($roleValue, $roles)) { - throw new \App\Exceptions\RuntimeException('没有权限'); + if (in_array($roleValue, $roles)) { + $hasPermissions = true; } } + if (!$hasPermissions) { + throw new \App\Exceptions\RuntimeException('没有权限'); + } return $next($request); } } diff --git a/database/migrations/2024_03_27_113404_create_workflows_table.php b/database/migrations/2024_03_27_113404_create_workflows_table.php index cc174d0..97a2ccf 100644 --- a/database/migrations/2024_03_27_113404_create_workflows_table.php +++ b/database/migrations/2024_03_27_113404_create_workflows_table.php @@ -28,6 +28,7 @@ return new class extends Migration $table->morphs('subject'); $table->json('subject_data')->nullable('审核内容'); $table->foreignId('employee_id')->nullable()->comment('申请人, employees.id'); + $table->timestamp('apply_at')->nullable()->comment('审批申请时间'); $table->unsignedInteger('check_status')->default(CheckStatus::None->value)->comment('审核状态'); $table->timestamp('checked_at')->nullable()->comment('审核通过时间'); $table->string('check_remarks')->nullable()->comment('审核未通过原因'); diff --git a/database/migrations/2024_04_28_230319_add_apply_at_to_workflow_checks_table.php b/database/migrations/2024_04_28_230319_add_apply_at_to_workflow_checks_table.php deleted file mode 100644 index 1e78f11..0000000 --- a/database/migrations/2024_04_28_230319_add_apply_at_to_workflow_checks_table.php +++ /dev/null @@ -1,28 +0,0 @@ -timestamp('apply_at')->nullable()->comment('审批申请时间'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('workflow_checks', function (Blueprint $table) { - $table->dropColumn(['apply_at']); - }); - } -};