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 WordsModel(BaseModel):
    """
    引导词表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    guide_id: Optional[int] = Field(default=None, description='引导词id')
    type: Optional[str] = Field(default=None, description='引导词类型')
    text: Optional[str] = Field(default=None, description='文本内容')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')
    update_time: Optional[datetime] = Field(default=None, description='修改时间')
    create_by: Optional[str] = Field(default=None, description='创建者')
    remark: Optional[str] = Field(default=None, description='备注')
    del_flag: Optional[str] = Field(default=None, description='删除标志（0代表存在 2代表删除）')
    update_by : Optional[str] = Field(default=None, description='修改者')
    title: Optional[str] = Field(default=None, description='引导词名称')
    label: Optional[str] = Field(default=None, description='引导词标签')
    trigger_type: Optional[str] = Field(default=None, description='触发方式')




    # @NotBlank(field_name='del_flag', message='删除标志不能为空')
    def get_del_flag(self):
        return self.del_flag

    def validate_fields(self):
        self.get_del_flag()

class WordsUpdateModel(WordsModel):
    """
    引导词更新模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    guide_id: int = Field(description='引导词id')
    text: str = Field(default=None, description='文本内容')
    type: Optional[str] = Field(default=None, description='引导词类型')
    remark : Optional[str] = Field(default=None, description='备注')
    update_time: Optional[datetime] = Field(default=None, description='修改时间')
    update_by : Optional[str] = Field(default=None, description='修改者')


class WordsQueryModel(WordsModel):
    """
    引导词不分页查询模型
    """
    begin_time: Optional[str] = Field(default=None, description='开始时间')
    end_time: Optional[str] = Field(default=None, description='结束时间')


@as_query
class WordsPageQueryModel(WordsQueryModel):
    """
    引导词分页查询模型
    """


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


class DeleteWordsModel(BaseModel):
    """
    删除引导词模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    guide_ids: str = Field(description='需要删除的引导词id')
