Update app/products/web/admin/tokens.py
Browse files
app/products/web/admin/tokens.py
CHANGED
|
@@ -34,7 +34,10 @@ if TYPE_CHECKING:
|
|
| 34 |
from app.control.account.repository import AccountRepository
|
| 35 |
|
| 36 |
from . import get_refresh_svc, get_repo
|
|
|
|
|
|
|
| 37 |
|
|
|
|
| 38 |
router = APIRouter(tags=["Admin - Tokens"])
|
| 39 |
_background_tasks: set[asyncio.Task] = set()
|
| 40 |
|
|
@@ -170,6 +173,17 @@ def _schedule_auto_nsfw(
|
|
| 170 |
# Endpoints
|
| 171 |
# ---------------------------------------------------------------------------
|
| 172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
@router.get("/tokens")
|
| 174 |
async def list_tokens(repo: "AccountRepository" = Depends(get_repo)):
|
| 175 |
"""Return flat token list."""
|
|
|
|
| 34 |
from app.control.account.repository import AccountRepository
|
| 35 |
|
| 36 |
from . import get_refresh_svc, get_repo
|
| 37 |
+
from fastapi import APIRouter, Query
|
| 38 |
+
from app.control.account.runtime import global_auditor
|
| 39 |
|
| 40 |
+
router = APIRouter()
|
| 41 |
router = APIRouter(tags=["Admin - Tokens"])
|
| 42 |
_background_tasks: set[asyncio.Task] = set()
|
| 43 |
|
|
|
|
| 173 |
# Endpoints
|
| 174 |
# ---------------------------------------------------------------------------
|
| 175 |
|
| 176 |
+
@router.get("/api/admin/audit/logs")
|
| 177 |
+
async def get_total_audit_logs(page: int = 1, size: int = 50):
|
| 178 |
+
# 调用总数审计明细
|
| 179 |
+
return {"logs": global_auditor.get_logs(page=page, page_size=size)}
|
| 180 |
+
|
| 181 |
+
@router.get("/api/admin/audit/distribution")
|
| 182 |
+
async def get_quota_distribution(type: str = Query(..., description="fast or console")):
|
| 183 |
+
# 详细 Fast/Console 额度调用分布审计
|
| 184 |
+
return global_auditor.get_distribution(quota_type=type)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
@router.get("/tokens")
|
| 188 |
async def list_tokens(repo: "AccountRepository" = Depends(get_repo)):
|
| 189 |
"""Return flat token list."""
|