Files
ai-contract-platform/backend/app/api/operation_kpis.py
T
yuqei 3df85fdb04 feat: land phase15 legal docs and commercial ops
Includes legal document generation workflows, prompt governance runtime wiring, legal change impact scans, operation KPI dashboards, invoice files, sales follow-up events, mobile review polish, deployment automation, and updated project docs.
2026-05-21 14:42:44 +08:00

35 lines
1.1 KiB
Python

from typing import Optional
from fastapi import APIRouter, Depends, Header
from sqlalchemy.orm import Session
from app.core.response import success_response
from app.db import get_db_session
from app.services.auth_service import AuthService
from app.services.operation_kpi_service import OperationKpiService
router = APIRouter(prefix="/operation-kpis", tags=["operation-kpis"])
ROUTE_PERMISSION_SCOPE = "operation_kpis"
ROUTE_PERMISSION_ACTIONS = {
"dashboard": "operation_kpis:dashboard",
}
def get_operation_kpi_service(db: Session = Depends(get_db_session)) -> OperationKpiService:
return OperationKpiService(db)
def require_current_user(
authorization: Optional[str] = Header(default=None),
db: Session = Depends(get_db_session),
):
return AuthService(db).require_current_user(authorization)
@router.get("/dashboard")
def get_operation_kpi_dashboard(
operation_kpi_service: OperationKpiService = Depends(get_operation_kpi_service),
current_user: dict = Depends(require_current_user),
):
return success_response(operation_kpi_service.get_dashboard(current_user))