This commit is contained in:
Your Name
2026-07-23 13:13:31 +08:00
parent 1a3c2d15c8
commit 5b93e4536f
16 changed files with 302 additions and 68 deletions
+3 -2
View File
@@ -5,6 +5,7 @@ from typing import Optional
from app.core.database import get_db
from app.core.security import get_current_user
from app.services.alert_service import AlertService
from app.schemas._tz_util import serialize_dt_fields, serialize_dt_list, to_business_iso
router = APIRouter(
prefix="/alerts",
@@ -37,7 +38,7 @@ def get_alerts(
total = query.count()
items = query.order_by(Alert.created_at.desc()).offset(skip).limit(limit).all()
return {"total": total, "items": items}
return {"total": total, "items": serialize_dt_list(items)}
@router.get("/{alert_id}", summary="获取告警详情")
@@ -47,7 +48,7 @@ def get_alert(alert_id: int, db: Session = Depends(get_db)):
alert = db.query(Alert).filter(Alert.id == alert_id).first()
if not alert:
raise HTTPException(status_code=404, detail="告警不存在")
return alert
return serialize_dt_fields(alert)
@router.post("/{alert_id}/acknowledge", summary="确认告警")