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

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


class ResourcesMaterial(Base, TimestampMixin, SoftDeleteMixin):
    __tablename__ = "resources_material"

    id: Mapped[str] = mapped_column(
        String(32), primary_key=True, comment="主键"
    )
    oauth_id: Mapped[str] = mapped_column(
        String(64), nullable=False, index=True, comment="授权表user_oauth自增id"
    )
    advertiser_id: Mapped[str | None] = mapped_column(
        String(64), nullable=True, index=True, comment="广告主id"
    )
    target_table: Mapped[str | None] = mapped_column(
        String(64), nullable=True,  comment="资源表名称"
    )
    target_id: Mapped[str | None] = mapped_column(
        String(64), nullable=True, comment="资源表id"
    )
    material_id: Mapped[str | None] = mapped_column(
        String(64), nullable=True, index=True, comment="素材id"
    )
    upload_id: Mapped[str | None] = mapped_column(
        String(128), nullable=True,  comment="上传资源平台id，图片id，视频id"
    )
    resource_type: Mapped[str | None] = mapped_column(
        String(16), nullable=True,  comment="资源类型，image或者video"
    )
    user_id: Mapped[str | None] = mapped_column(
        String(64), nullable=True, index=True, comment="用户登录id"
    )
    task_id: Mapped[str | None] = mapped_column(
        String(32), nullable=True, index=True, comment="前测任务id"
    )
    note: Mapped[str | None] = mapped_column(
        Text, nullable=True, comment="前测失败备注或者其他备注"
    )
    status: Mapped[str | None] = mapped_column(
        String(16), nullable=True, comment="前测状态（FAILED/PENDING/SUCCESS）"
    )
    pre_result: Mapped[str | None] = mapped_column(
        Text, nullable=True, comment="前测结果，JSON数组对象"
    )
    pre_test_template_id: Mapped[str | None] = mapped_column(
        String(32), nullable=True, comment="前测模板id"
    )