from typing import Optional

from sqlmodel import SQLModel, Field

from entity.base import TimestampMixin


class DeviceModelRelationBase(SQLModel):
    algo_model_id: int
    is_use: int
    threshold: Optional[float] = None


class DeviceModelRelation(DeviceModelRelationBase, TimestampMixin, table=True):
    __tablename__ = 'device_model_relation'
    id: Optional[int] = Field(default=None, primary_key=True)
    device_id: int

class DeviceModelRelationCreate(DeviceModelRelationBase):
    # 批量新增，device_id单独传参，不在DeviceModelRelationCreate对象中
    pass


class DeviceModelRelationInfo(DeviceModelRelationBase, TimestampMixin):
    id: int
    device_id: int
    algo_model_name: str
    algo_model_version: str
    algo_model_path: Optional[str] = None  # 可选字段
    algo_model_remark: Optional[str] = None
