feat: 重构接口日志页面与接口监控看板,支持HTTP方法过滤和实时轮询

This commit is contained in:
liumangmang
2026-07-01 15:04:32 +08:00
parent 397a14c978
commit 8abfa4c5ef
19 changed files with 2463 additions and 37 deletions
+1
View File
@@ -1 +1,2 @@
# models package
from app.models.external_api_log import ExternalApiLog
+28
View File
@@ -0,0 +1,28 @@
from datetime import datetime, timezone
from typing import Optional
from sqlalchemy import Index, Integer, String, DateTime, Boolean, text
from sqlalchemy.orm import mapped_column, Mapped
from app.database import Base
class ExternalApiLog(Base):
__tablename__ = "external_api_logs"
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
direction: Mapped[str] = mapped_column(String(32), index=True) # "upstream" | "website"
target_type: Mapped[str] = mapped_column(String(32), index=True) # "upstream" | "website"
target_id: Mapped[Optional[int]] = mapped_column(Integer, nullable=True, index=True)
target_name: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
method: Mapped[str] = mapped_column(String(16))
path: Mapped[str] = mapped_column(String(1024))
url_host: Mapped[str] = mapped_column(String(255))
status_code: Mapped[Optional[int]] = mapped_column(Integer, nullable=True, index=True)
success: Mapped[bool] = mapped_column(Boolean, default=True, index=True)
duration_ms: Mapped[int] = mapped_column(Integer)
error_type: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
error_message: Mapped[Optional[str]] = mapped_column(String(1024), nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, default=lambda: datetime.now(timezone.utc), index=True)
__table_args__ = (
Index("ix_external_api_logs_created_at_desc", text("created_at DESC")),
)