from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel
from typing import Optional
from module_admin.annotation.pydantic_annotation import as_query




class DoorModel(BaseModel):
    """
    门禁设备表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='主键自增')
    indexCode: Optional[str] = Field(default=None, description='设备索引编码')
    name: Optional[str] = Field(default=None, description='门禁名称')
    install_location: Optional[str] = Field(default=None, description='位置名称')
    status: Optional[str] = Field(default=None, description='设备状态, 0 离线, 1 正常在线')
    permission: Optional[str] = Field(default=None, description='权限, 0 禁用, 1 正常调用')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')
    create_by: Optional[str] = Field(default=None, description='创建者')
    update_time: Optional[datetime] = Field(default=None, description='更新时间')
    update_by: Optional[str] = Field(default=None, description='更新者')






class DoorQueryModel(DoorModel):
    """
    门禁设备不分页查询模型
    """
    key_word : Optional[str] = Field(default=None, description='模糊查询字段')
    


@as_query
class DoorPageQueryModel(DoorQueryModel):
    """
    门禁设备分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeleteDoorModel(BaseModel):
    """
    删除门禁设备模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    ids: str = Field(description='需要删除的主键自增')
