feat: Add AI report generation with DIFY integration

- Add Users table for display name resolution from AD authentication
- Integrate DIFY AI service for report content generation
- Create docx assembly service with image embedding from MinIO
- Add REST API endpoints for report generation and download
- Add WebSocket notifications for generation progress
- Add frontend UI with progress modal and download functionality
- Add integration tests for report generation flow

Report sections (Traditional Chinese):
- 事件摘要 (Summary)
- 時間軸 (Timeline)
- 參與人員 (Participants)
- 處理過程 (Resolution Process)
- 目前狀態 (Current Status)
- 最終處置結果 (Final Resolution)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-04 18:32:40 +08:00
parent 77091eefb5
commit 3927441103
32 changed files with 4374 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ from app.modules.auth.schemas import LoginRequest, LoginResponse, LogoutResponse
from app.modules.auth.services.ad_client import ad_auth_service
from app.modules.auth.services.encryption import encryption_service
from app.modules.auth.services.session_service import session_service
from app.modules.auth.services.user_service import upsert_user
from fastapi import Header
from typing import Optional
@@ -30,10 +31,11 @@ async def login(request: LoginRequest, db: Session = Depends(get_db)):
流程:
1. 呼叫 AD API 驗證憑證
2. 加密密碼(用於自動刷新
3. 生成 internal token (UUID)
4. 儲存 session 到資料庫
5. 回傳 internal token 和 display_name
2. 儲存/更新使用者資訊到 users 表(用於報告姓名解析
3. 加密密碼(用於自動刷新)
4. 生成 internal token (UUID)
5. 儲存 session 到資料庫
6. 回傳 internal token 和 display_name
"""
try:
# Step 1: Authenticate with AD API
@@ -52,10 +54,19 @@ async def login(request: LoginRequest, db: Session = Depends(get_db)):
detail="Authentication service unavailable",
)
# Step 2: Encrypt password for future auto-refresh
# Step 2: Upsert user info for report generation (permanent storage)
upsert_user(
db=db,
user_id=ad_result["email"],
display_name=ad_result["username"],
office_location=ad_result.get("office_location"),
job_title=ad_result.get("job_title"),
)
# Step 3: Encrypt password for future auto-refresh
encrypted_password = encryption_service.encrypt_password(request.password)
# Step 3 & 4: Generate internal token and create session
# Step 4 & 5: Generate internal token and create session
user_session = session_service.create_session(
db=db,
username=request.username,