This commit is contained in:
2026-06-14 09:25:59 +08:00
parent a0f441d8ae
commit 6fbf610277
39 changed files with 2492 additions and 2 deletions
+38
View File
@@ -0,0 +1,38 @@
"""聊天气候路由"""
from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.ext.asyncio import AsyncSession
from app.dependencies import get_db, get_current_user
from app.models.user import User
from app.services.climate_service import ClimateService
router = APIRouter()
@router.get("/{conversation_id}")
async def get_climate(
conversation_id: str,
user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
):
"""获取/计算会话气候"""
service = ClimateService(db)
try:
return await service.compute(conversation_id, user.id)
except ValueError as e:
raise HTTPException(status_code=403, detail=str(e))
@router.get("/{conversation_id}/calendar")
async def get_calendar(
conversation_id: str,
user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
):
"""获取 30 天气候日历"""
service = ClimateService(db)
try:
return await service.get_calendar(conversation_id, user.id)
except ValueError as e:
raise HTTPException(status_code=403, detail=str(e))