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




class Visitor_typeModel(BaseModel):
    """
    访客类型表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    type_id: Optional[int] = Field(default=None, description='访客类型ID')
    name: Optional[str] = Field(default=None, description='类型名称')
    value: Optional[str] = Field(default=None, description='类型值')
    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='修改者')

    @NotBlank(field_name='value', message='类型值不能为空')
    def get_value(self):
        return self.value


    def validate_fields(self):
        self.get_value()




class Visitor_typeQueryModel(Visitor_typeModel):
    """
    访客类型不分页查询模型
    """
    pass


@as_query
class Visitor_typePageQueryModel(Visitor_typeQueryModel):
    """
    访客类型分页查询模型
    """

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


class DeleteVisitor_typeModel(BaseModel):
    """
    删除访客类型模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    type_ids: str = Field(description='需要删除的访客类型ID')
