feat: [flow-tester] 플로우 실행 기능 완성

- FlowTesterController에 FlowExecutor 연결
- 실행 결과를 AdminApiFlowRun에 저장
- 실행 중 로딩 인디케이터 추가
- 결과 모달로 상세 실행 결과 표시
  - 상태, 소요 시간, 완료 스텝 표시
  - 각 스텝별 성공/실패 로그 표시
  - 상세 보기 링크 제공
This commit is contained in:
2025-11-27 20:25:32 +09:00
parent 3dcad4e00c
commit 28ca71a17e
2 changed files with 162 additions and 13 deletions

View File

@@ -5,6 +5,7 @@
use App\Http\Controllers\Controller;
use App\Models\Admin\AdminApiFlow;
use App\Models\Admin\AdminApiFlowRun;
use App\Services\FlowTester\FlowExecutor;
use Illuminate\Http\Request;
use Illuminate\View\View;
@@ -216,14 +217,57 @@ public function run(int $id)
'executed_by' => auth()->id(),
]);
// TODO: 실제 플로우 실행 로직은 Service 클래스로 분리
// 현재는 스캐폴딩만 제공
try {
// FlowExecutor로 실제 실행
$executor = new FlowExecutor();
$result = $executor->execute($flow->flow_definition);
return response()->json([
'success' => true,
'run_id' => $run->id,
'message' => '플로우 실행이 시작되었습니다.',
]);
// 실행 결과 저장
$run->update([
'status' => $result['status'],
'completed_at' => now(),
'duration_ms' => $result['duration'],
'completed_steps' => $result['completedSteps'],
'failed_step' => $result['failedStep'],
'execution_log' => $result['executionLog'],
'error_message' => $result['errorMessage'],
]);
return response()->json([
'success' => $result['status'] === 'SUCCESS',
'run_id' => $run->id,
'status' => $result['status'],
'message' => $this->getResultMessage($result),
'result' => $result,
]);
} catch (\Exception $e) {
// 예외 발생 시 실패 처리
$run->update([
'status' => AdminApiFlowRun::STATUS_FAILED,
'completed_at' => now(),
'error_message' => $e->getMessage(),
]);
return response()->json([
'success' => false,
'run_id' => $run->id,
'status' => 'FAILED',
'message' => '실행 오류: '.$e->getMessage(),
], 500);
}
}
/**
* 실행 결과 메시지 생성
*/
private function getResultMessage(array $result): string
{
return match ($result['status']) {
'SUCCESS' => "플로우 실행 완료! ({$result['completedSteps']}/{$result['totalSteps']} 스텝 성공)",
'FAILED' => "플로우 실행 실패: ".($result['errorMessage'] ?? '알 수 없는 오류'),
'PARTIAL' => "부분 성공: {$result['completedSteps']}/{$result['totalSteps']} 스텝 완료",
default => "실행 완료 (상태: {$result['status']})",
};
}
/**