from datetime import datetime from sqlalchemy import Boolean, DateTime, Integer, String, Text, func from sqlalchemy.orm import Mapped, mapped_column from app.database import Base class SourceSite(Base): __tablename__ = "source_site" id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) name: Mapped[str] = mapped_column(String(50), nullable=False, comment="站点名称") code: Mapped[str] = mapped_column(String(30), unique=True, nullable=False, comment="站点编码") base_url: Mapped[str] = mapped_column(String(500), nullable=False, comment="API基础地址") site_url: Mapped[str | None] = mapped_column(String(500), comment="官网地址") play_from_m3u8: Mapped[str | None] = mapped_column(String(30), comment="M3U8来源标识") play_from_yun: Mapped[str | None] = mapped_column(String(30), comment="云播来源标识") parse_url: Mapped[str | None] = mapped_column(String(500), comment="M3U8解析接口") is_active: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否启用") sync_interval: Mapped[int] = mapped_column(Integer, default=60, comment="同步间隔(分钟)") last_sync_at: Mapped[datetime | None] = mapped_column(DateTime, comment="最后同步时间") last_sync_status: Mapped[str | None] = mapped_column(String(20), comment="最后同步状态") last_sync_count: Mapped[int] = mapped_column(Integer, default=0, comment="最后同步新增数量") total_count: Mapped[int] = mapped_column(Integer, default=0, comment="资源总数") sort_order: Mapped[int] = mapped_column(Integer, default=0, comment="排序权重") remark: Mapped[str | None] = mapped_column(String(200), comment="备注") created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now()) updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())