from sqlmodel import Field
from sqlalchemy import VARCHAR

from .base import BaseModel


class DomainModel(BaseModel, table=True):
    """存储根域名"""

    __tablename__ = 'domain'

    # 域名
    domain: str = Field(alias="domain", default="", sa_type=VARCHAR(1024))

    # 爬取状态，@see constants.DomainStatus
    status: int = Field(alias="status", default=0)

    # 爬取间隔，默认间隔为1周
    crawl_interval: int = Field(alias="crawl_interval", default=60 * 24 * 7)

    # 最近一次爬取时间，精确到秒的时间戳
    latest_crawl_time: int = Field(alias="latest_crawl_time", default=0)
