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']); - }); - } -};