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

from db.db_base import BaseModel


class ProjectDetect(BaseModel):
    """
    项目推理集合
    """
    __tablename__ = "project_detect"
    __table_args__ = ({'comment': '项目推理集合'})

    project_id: Mapped[int] = mapped_column(Integer, nullable=False)
    detect_name: Mapped[str] = mapped_column(String(64), nullable=False)
    detect_version: Mapped[int] = mapped_column(Integer)
    detect_no: Mapped[str] = mapped_column(String(32))
    detect_status: Mapped[int] = mapped_column(Integer)
    file_type: Mapped[str] = mapped_column(String(10))
    folder_url: Mapped[str] = mapped_column(String(255))
    rtsp_url: Mapped[str] = mapped_column(String(255))
    user_id: Mapped[int] = mapped_column(Integer, nullable=False)


class ProjectDetectImg(BaseModel):
    """
    待推理图片
    """
    __tablename__ = "project_detect_img"
    __table_args__ = ({'comment': '待推理图片'})

    detect_id: Mapped[int] = mapped_column(Integer, nullable=False)
    file_name: Mapped[str] = mapped_column(String(64), nullable=False)
    image_url: Mapped[str] = mapped_column(String(255), nullable=False)
    thumb_image_url: Mapped[str] = mapped_column(String(255), nullable=False)
    user_id: Mapped[int] = mapped_column(Integer, nullable=False)


class ProjectDetectLog(BaseModel):
    """
    项目推理记录
    """
    __tablename__ = "project_detect_log"
    __table_args__ = ({'comment': '项目推理记录'})

    detect_id: Mapped[int] = mapped_column(Integer, nullable=False)
    detect_version: Mapped[str] = mapped_column(String(10))
    detect_name: Mapped[str] = mapped_column(String(64), nullable=False)
    train_id: Mapped[int] = mapped_column(Integer, nullable=False)
    train_version: Mapped[str] = mapped_column(String(10))
    pt_type: Mapped[str] = mapped_column(String(10))
    pt_url: Mapped[str] = mapped_column(String(255))
    folder_url: Mapped[str] = mapped_column(String(255))
    detect_folder_url: Mapped[str] = mapped_column(String(255))
    user_id: Mapped[int] = mapped_column(Integer, nullable=False)


class ProjectDetectLogImg(BaseModel):
    """
    推理完成的图片
    """
    __tablename__ = "project_detect_log_img"
    __table_args__ = ({'comment': '项目训练版本信息表'})

    log_id: Mapped[int] = mapped_column(Integer, nullable=False)
    file_name: Mapped[str] = mapped_column(String(64), nullable=False)
    image_url: Mapped[str] = mapped_column(String(255), nullable=False)