main
panliang 2024-04-29 10:17:54 +08:00
parent de8e11dfae
commit 26c879b954
3 changed files with 7 additions and 30 deletions

View File

@ -18,12 +18,16 @@ class CheckUserRole
{ {
$user = auth('api')->user(); $user = auth('api')->user();
$currentRole = $user->userRole(); $currentRole = $user->userRole();
$hasPermissions = false;
foreach ($currentRole as $role) { foreach ($currentRole as $role) {
$roleValue = $role->value; $roleValue = $role->value;
if (!in_array($roleValue, $roles)) { if (in_array($roleValue, $roles)) {
throw new \App\Exceptions\RuntimeException('没有权限'); $hasPermissions = true;
} }
} }
if (!$hasPermissions) {
throw new \App\Exceptions\RuntimeException('没有权限');
}
return $next($request); return $next($request);
} }
} }

View File

@ -28,6 +28,7 @@ return new class extends Migration
$table->morphs('subject'); $table->morphs('subject');
$table->json('subject_data')->nullable('审核内容'); $table->json('subject_data')->nullable('审核内容');
$table->foreignId('employee_id')->nullable()->comment('申请人, employees.id'); $table->foreignId('employee_id')->nullable()->comment('申请人, employees.id');
$table->timestamp('apply_at')->nullable()->comment('审批申请时间');
$table->unsignedInteger('check_status')->default(CheckStatus::None->value)->comment('审核状态'); $table->unsignedInteger('check_status')->default(CheckStatus::None->value)->comment('审核状态');
$table->timestamp('checked_at')->nullable()->comment('审核通过时间'); $table->timestamp('checked_at')->nullable()->comment('审核通过时间');
$table->string('check_remarks')->nullable()->comment('审核未通过原因'); $table->string('check_remarks')->nullable()->comment('审核未通过原因');

View File

@ -1,28 +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.
*/
public function up(): void
{
Schema::table('workflow_checks', function (Blueprint $table) {
$table->timestamp('apply_at')->nullable()->comment('审批申请时间');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('workflow_checks', function (Blueprint $table) {
$table->dropColumn(['apply_at']);
});
}
};