Files
bxh/app/api/treatment_history.py

28 lines
953 B
Python

"""STEP 04 — Treatment History (历史治理记录)."""
from fastapi import APIRouter, Depends
from app.auth import CurrentUser
from app.config import settings
from app.db import get_conn
router = APIRouter()
@router.get("/treatment-history")
async def _list(limit: int = 50, _user: CurrentUser = None):
s = settings.db_schema
async with get_conn() as conn:
async with conn.cursor() as cur:
await cur.execute(
f"""SELECT
ra.id, ra.candidate_id, ra.candidate_type,
ra.action, ra.actor, ra.note, ra.field_decisions_jsonb,
ra.created_at,
ce.entity_type, ce.natural_key
FROM {s}.review_actions ra
LEFT JOIN {s}.candidate_entities ce ON ra.candidate_id=ce.id
ORDER BY ra.created_at DESC LIMIT %s""",
(limit,),
)
return await cur.fetchall()