1.7
This commit is contained in:
@@ -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))
|
||||
Reference in New Issue
Block a user