add jose
This commit is contained in:
@@ -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="确认告警")
|
||||
|
||||
Reference in New Issue
Block a user