From 753ecdbbf27421a57e660a4fab2e11b3b7821c25 Mon Sep 17 00:00:00 2001 From: gahusb Date: Wed, 15 Apr 2026 08:24:06 +0900 Subject: [PATCH] =?UTF-8?q?feat(lotto):=20briefing=20CRUD=20+=20=ED=81=90?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=ED=84=B0=20=EC=82=AC=EC=9A=A9=EB=9F=89=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=ED=84=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/briefing.py | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 backend/app/routers/briefing.py diff --git a/backend/app/routers/briefing.py b/backend/app/routers/briefing.py new file mode 100644 index 0000000..b4e0fb4 --- /dev/null +++ b/backend/app/routers/briefing.py @@ -0,0 +1,53 @@ +"""브리핑 저장/조회 + 큐레이터 사용량 엔드포인트.""" +from typing import Any, Dict, List +from fastapi import APIRouter, HTTPException +from pydantic import BaseModel, Field +from .. import db + +router = APIRouter(prefix="/api/lotto") + + +class BriefingRequest(BaseModel): + draw_no: int + picks: List[Dict[str, Any]] + narrative: Dict[str, Any] + confidence: int = Field(ge=0, le=100) + model: str + tokens_input: int = 0 + tokens_output: int = 0 + cache_read: int = 0 + cache_write: int = 0 + latency_ms: int = 0 + source: str = "auto" + + +@router.post("/briefing", status_code=201) +def save_briefing(body: BriefingRequest): + bid = db.save_briefing(body.model_dump()) + return {"ok": True, "id": bid} + + +@router.get("/briefing/latest") +def latest(): + b = db.get_latest_briefing() + if not b: + raise HTTPException(404, "no briefing yet") + return b + + +@router.get("/briefing/{draw_no}") +def get_one(draw_no: int): + b = db.get_briefing(draw_no) + if not b: + raise HTTPException(404, f"no briefing for draw {draw_no}") + return b + + +@router.get("/briefing") +def history(limit: int = 10): + return {"briefings": db.list_briefings(limit)} + + +@router.get("/curator/usage") +def usage(days: int = 30): + return db.get_curator_usage(days)