- MeetingLog 모델 (BelongsToTenant, SoftDeletes) - GoogleCloudService (GCS 업로드, STT API) - MeetingLogService (Claude API 요약) - MeetingLogController (HTMX/JSON 듀얼 응답) - 순수 Tailwind CSS UI 구현 - API 라우트 8개 엔드포인트 등록
218 lines
5.7 KiB
PHP
218 lines
5.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\MeetingLog;
|
|
use App\Services\MeetingLogService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
/**
|
|
* 회의록 API 컨트롤러 (웹 녹음 AI 요약)
|
|
*/
|
|
class MeetingLogController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly MeetingLogService $meetingLogService
|
|
) {}
|
|
|
|
/**
|
|
* 회의록 목록 (HTMX용)
|
|
*/
|
|
public function index(Request $request): View|JsonResponse
|
|
{
|
|
$params = $request->only(['search', 'status', 'per_page']);
|
|
$meetings = $this->meetingLogService->getList($params);
|
|
|
|
if ($request->header('HX-Request')) {
|
|
return view('lab.ai.web-recording.partials.list', compact('meetings'));
|
|
}
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'data' => $meetings,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 회의록 상세 조회
|
|
*/
|
|
public function show(int $id): JsonResponse
|
|
{
|
|
$meeting = $this->meetingLogService->getById($id);
|
|
|
|
if (! $meeting) {
|
|
return response()->json([
|
|
'success' => false,
|
|
'message' => '회의록을 찾을 수 없습니다.',
|
|
], 404);
|
|
}
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'data' => $meeting,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 회의록 생성 (녹음 시작)
|
|
*/
|
|
public function store(Request $request): JsonResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'title' => 'nullable|string|max:200',
|
|
]);
|
|
|
|
$meeting = $this->meetingLogService->create($validated);
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'message' => '회의록이 생성되었습니다.',
|
|
'data' => $meeting,
|
|
], 201);
|
|
}
|
|
|
|
/**
|
|
* 오디오 업로드 및 처리
|
|
*/
|
|
public function processAudio(Request $request, int $id): JsonResponse
|
|
{
|
|
$meeting = MeetingLog::find($id);
|
|
|
|
if (! $meeting) {
|
|
return response()->json([
|
|
'success' => false,
|
|
'message' => '회의록을 찾을 수 없습니다.',
|
|
], 404);
|
|
}
|
|
|
|
$validated = $request->validate([
|
|
'audio' => 'required|string', // Base64 인코딩된 오디오
|
|
'duration' => 'required|integer|min:1', // 녹음 시간(초)
|
|
]);
|
|
|
|
$result = $this->meetingLogService->processAudio(
|
|
$meeting,
|
|
$validated['audio'],
|
|
$validated['duration']
|
|
);
|
|
|
|
if (! $result['ok']) {
|
|
return response()->json([
|
|
'success' => false,
|
|
'message' => $result['error'] ?? '처리 중 오류가 발생했습니다.',
|
|
], 500);
|
|
}
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'message' => '회의록이 생성되었습니다.',
|
|
'data' => $result['meeting'],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 제목 업데이트
|
|
*/
|
|
public function updateTitle(Request $request, int $id): JsonResponse
|
|
{
|
|
$meeting = MeetingLog::find($id);
|
|
|
|
if (! $meeting) {
|
|
return response()->json([
|
|
'success' => false,
|
|
'message' => '회의록을 찾을 수 없습니다.',
|
|
], 404);
|
|
}
|
|
|
|
$validated = $request->validate([
|
|
'title' => 'required|string|max:200',
|
|
]);
|
|
|
|
$meeting = $this->meetingLogService->updateTitle($meeting, $validated['title']);
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'message' => '제목이 업데이트되었습니다.',
|
|
'data' => $meeting,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 회의록 삭제
|
|
*/
|
|
public function destroy(int $id): JsonResponse
|
|
{
|
|
$meeting = MeetingLog::find($id);
|
|
|
|
if (! $meeting) {
|
|
return response()->json([
|
|
'success' => false,
|
|
'message' => '회의록을 찾을 수 없습니다.',
|
|
], 404);
|
|
}
|
|
|
|
$this->meetingLogService->delete($meeting);
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'message' => '회의록이 삭제되었습니다.',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 처리 상태 확인 (폴링용)
|
|
*/
|
|
public function status(int $id): JsonResponse
|
|
{
|
|
$meeting = MeetingLog::find($id);
|
|
|
|
if (! $meeting) {
|
|
return response()->json([
|
|
'success' => false,
|
|
'message' => '회의록을 찾을 수 없습니다.',
|
|
], 404);
|
|
}
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'data' => [
|
|
'id' => $meeting->id,
|
|
'status' => $meeting->status,
|
|
'status_label' => $meeting->status_label,
|
|
'is_completed' => $meeting->isCompleted(),
|
|
'is_processing' => $meeting->isProcessing(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 요약 결과 조회 (HTMX용)
|
|
*/
|
|
public function summary(int $id): View|JsonResponse
|
|
{
|
|
$meeting = $this->meetingLogService->getById($id);
|
|
|
|
if (! $meeting) {
|
|
return response()->json([
|
|
'success' => false,
|
|
'message' => '회의록을 찾을 수 없습니다.',
|
|
], 404);
|
|
}
|
|
|
|
if (request()->header('HX-Request')) {
|
|
return view('lab.ai.web-recording.partials.summary', compact('meeting'));
|
|
}
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'data' => [
|
|
'transcript' => $meeting->transcript_text,
|
|
'summary' => $meeting->summary_text,
|
|
],
|
|
]);
|
|
}
|
|
}
|