from sqlalchemy import String, Text, Integer
from sqlalchemy.orm import Mapped, mapped_column

from app.models.base import Base, TimestampMixin, SoftDeleteMixin


class UploadTask(Base, TimestampMixin, SoftDeleteMixin):
    __tablename__ = "upload_task"

    id: Mapped[str] = mapped_column(
        String(32), primary_key=True, comment="主键"
    )
    user_id: Mapped[str] = mapped_column(
        String(64), nullable=False, index=True, comment="用户登录id"
    )
    advertiser_id: Mapped[str] = mapped_column(
        String(64), nullable=False, index=True, comment="广告主id"
    )
    resource_id: Mapped[str] = mapped_column(
        String(64), nullable=False, index=True, comment="资源id"
    )
    status: Mapped[int] = mapped_column(
        Integer, nullable=False, default=1, comment="上传状态：1待上传，2上传中，3上传成功，4上传失败"
    )
    note: Mapped[str | None] = mapped_column(
        Text, nullable=True, comment="上传备注"
    )
    oauth_id: Mapped[str] = mapped_column(
        String(64), nullable=False, index=True, comment="授权表id"
    )
    other_info: Mapped[str | None] = mapped_column(
        String(500), nullable=True, comment="其他信息"
    )
