refactor: [approval] SAM API 규칙 준수 코드 리뷰 반영

- ApprovalStep에 BelongsToTenant, SoftDeletes 추가 (마이그레이션 포함)
- ApprovalForm, ApprovalDelegation에 ModelTrait 추가 (중복 scopeActive 제거)
- ApprovalDelegation에 Auditable 추가
- 모든 결재 액션에 FormRequest 적용 (approve, cancel, hold, preDecide)
- 위임 CRUD에 DelegationStoreRequest, DelegationUpdateRequest 적용
- ApprovalStep 생성 시 tenant_id 포함
This commit is contained in:
김보곤
2026-03-11 17:13:08 +09:00
parent 3fd412f89d
commit 0be88f95ca
12 changed files with 204 additions and 33 deletions

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('approval_steps', function (Blueprint $table) {
$table->unsignedBigInteger('tenant_id')->nullable()->after('id')->comment('테넌트 ID');
$table->softDeletes()->comment('삭제일시');
$table->index('tenant_id', 'idx_approval_steps_tenant');
});
// 기존 데이터: 부모 approvals 테이블에서 tenant_id 복사
DB::statement('
UPDATE approval_steps AS s
INNER JOIN approvals AS a ON s.approval_id = a.id
SET s.tenant_id = a.tenant_id
');
}
public function down(): void
{
Schema::table('approval_steps', function (Blueprint $table) {
$table->dropIndex('idx_approval_steps_tenant');
$table->dropColumn(['tenant_id', 'deleted_at']);
});
}
};