feat: DSH编排基建首版(server/tests 88用例/P2插件/8020端口/PORT-NOTE/MOBILE_APP)

This commit is contained in:
2026-09-12 14:20:02 +08:00
commit f6acd20325
128 changed files with 24471 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
"""Admin-visible change history."""
from __future__ import annotations
import json
from fastapi import APIRouter, Depends, Request
from ..auth import Ctx
from ..deps import get_ctx
router = APIRouter()
@router.get("/v1/audit")
def get_audit(request: Request, ctx: Ctx = Depends(get_ctx), limit: int = 100, since: str | None = None):
ctx.require_admin(request)
q = "SELECT id, actor, action, detail_json, created_at FROM audit_log"
params: list = []
if since:
q += " WHERE created_at >= %s"
params.append(since)
q += " ORDER BY id DESC LIMIT %s"
params.append(max(1, min(limit, 500)))
events = []
for r in ctx.conn.execute(q, params).fetchall():
d = dict(r)
d["detail"] = json.loads(d.pop("detail_json"))
events.append(d)
return {"events": events}