from datetime import datetime, date
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 Sys_statisticsModel(BaseModel):
    """
    系统统计数据表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    statistic_id: Optional[int] = Field(default=None, description='统计项目ID')
    stat_date: Optional[date] = Field(default=None, description='统计日期')
    llm_call: Optional[int] = Field(default=None, description='大模型调用量')
    access_control_count: Optional[int] = Field(default=None, description='门禁通行量')
    visitor_guide: Optional[int] = Field(default=None, description='访客引导次数')
    exhibition_explanation: Optional[int] = Field(default=None, description='展厅讲解次数')
    access_control_success_rate: Optional[int] = 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='stat_date', message='统计日期不能为空')
    def get_stat_date(self):
        return self.stat_date

    @NotBlank(field_name='update_time', message='修改时间不能为空')
    def get_update_time(self):
        return self.update_time


    def validate_fields(self):
        self.get_stat_date()
        self.get_update_time()




class Sys_statisticsQueryModel(Sys_statisticsModel):
    """
    系统统计数据不分页查询模型
    """
    pass


@as_query
class Sys_statisticsPageQueryModel(Sys_statisticsQueryModel):
    """
    系统统计数据分页查询模型
    """

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


class DeleteSys_statisticsModel(BaseModel):
    """
    删除系统统计数据模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    statistic_ids: str = Field(description='需要删除的统计项目ID')
