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)
    detect_name: Mapped[str] = mapped_column(String(64))
    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), nullable=True)
    rtsp_url: Mapped[str] = mapped_column(String(255), nullable=True)
    user_id: Mapped[int] = mapped_column(Integer)


class ProjectDetectFile(BaseModel):
    """
    待推理图片
    """
    __tablename__ = "project_detect_file"
    __table_args__ = ({'comment': '待推理文件'})

    detect_id: Mapped[int] = mapped_column(Integer, nullable=False)
    file_name: Mapped[str] = mapped_column(String(64), nullable=False)
    file_url: Mapped[str] = mapped_column(String(255), nullable=False)
    object_key: Mapped[str] = mapped_column(String(255), nullable=False)
    thumb_file_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 ProjectDetectLogFile(BaseModel):
    """
    推理完成的图片
    """
    __tablename__ = "project_detect_log_file"
    __table_args__ = ({'comment': '项目训练版本信息表'})

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