Include Loyalty/Communication/Sports Center backends and registry updates alongside production nginx and compose wiring. Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""Audit log APIs — Phase 7.0."""
|
|
from __future__ import annotations
|
|
|
|
from uuid import UUID
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.api.deps import get_db, require_tenant
|
|
from app.api.permissions import require_permissions
|
|
from app.permissions.definitions import LOYALTY_AUDIT_VIEW
|
|
from app.schemas.foundation import LoyaltyAuditLogRead
|
|
from app.services.audit_service import AuditService
|
|
from shared.security import CurrentUser
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("", response_model=list[LoyaltyAuditLogRead])
|
|
async def list_audit(
|
|
entity_type: str = Query(..., min_length=1, max_length=50),
|
|
entity_id: UUID = Query(...),
|
|
limit: int = Query(default=100, ge=1, le=500),
|
|
tenant_id: UUID = Depends(require_tenant),
|
|
db: AsyncSession = Depends(get_db),
|
|
_user: CurrentUser = Depends(require_permissions(LOYALTY_AUDIT_VIEW)),
|
|
):
|
|
return await AuditService(db).list_for_entity(
|
|
tenant_id, entity_type, entity_id, limit=limit
|
|
)
|