feat: AI 리포트 API 구현 (Google Gemini 연동)

- ai_reports 테이블 마이그레이션 추가
- AiReport 모델 생성 (daily/weekly/monthly 유형)
- AiReportService 구현 (비즈니스 데이터 수집 + Gemini API)
- 4개 API 엔드포인트 추가 (목록/생성/상세/삭제)
- Swagger 문서 및 i18n 메시지 추가
This commit is contained in:
2025-12-18 13:51:40 +09:00
parent c7eee97610
commit 98645316fc
11 changed files with 1051 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?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::create('ai_reports', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->comment('테넌트 ID');
$table->date('report_date')->comment('리포트 기준일');
$table->string('report_type', 50)->default('daily')->comment('리포트 유형: daily/weekly/monthly');
$table->json('content')->nullable()->comment('리포트 내용 (영역별 분석 배열)');
$table->text('summary')->nullable()->comment('요약 메시지');
$table->json('input_data')->nullable()->comment('AI 분석에 사용된 입력 데이터');
$table->string('status', 20)->default('completed')->comment('상태: pending/completed/failed');
$table->text('error_message')->nullable()->comment('실패 시 에러 메시지');
$table->foreignId('created_by')->nullable()->constrained('users')->comment('생성자 ID');
$table->timestamps();
$table->index(['tenant_id', 'report_date'], 'idx_tenant_date');
$table->index(['tenant_id', 'report_type'], 'idx_tenant_type');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ai_reports');
}
};