Initial commit: svg backend
This commit is contained in:
31
backend/app/api/routes/audit.py
Normal file
31
backend/app/api/routes/audit.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from app.core.config import settings
|
||||
from app.repositories.audit import list_audit_events
|
||||
from app.repositories.schemes import get_scheme_record_by_scheme_id
|
||||
from app.schemas.audit import AuditEventItem, SchemeAuditResponse
|
||||
from app.security.auth import require_api_key
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get(f"{settings.api_v1_prefix}/schemes/{{scheme_id}}/audit", response_model=SchemeAuditResponse)
|
||||
async def get_scheme_audit(scheme_id: str, role: str = Depends(require_api_key)):
|
||||
await get_scheme_record_by_scheme_id(scheme_id)
|
||||
rows = await list_audit_events(scheme_id)
|
||||
|
||||
return SchemeAuditResponse(
|
||||
items=[
|
||||
AuditEventItem(
|
||||
audit_event_id=row.audit_event_id,
|
||||
scheme_id=row.scheme_id,
|
||||
event_type=row.event_type,
|
||||
object_type=row.object_type,
|
||||
object_ref=row.object_ref,
|
||||
details_json=row.details_json,
|
||||
created_at=row.created_at.isoformat(),
|
||||
)
|
||||
for row in rows
|
||||
],
|
||||
total=len(rows),
|
||||
)
|
||||
Reference in New Issue
Block a user