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 Explanation_contentModel(BaseModel):
    """
    讲解内容表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    explanation_content_id: Optional[int] = Field(default=None, description='主键ID')
    title: Optional[str] = Field(default=None, description='标题')
    content: Optional[str] = Field(default=None, description='讲解内容')
    type: Optional[str] = Field(default=None, description='类型(0科技类)')
    spend_time: Optional[int] = Field(default=None, description='预计时长(分钟)')
    language: Optional[str] = Field(default=None, description='语言(0中文,1英文)')
    status: Optional[str] = Field(default=None, description='状态(0未开始,1已就绪,2播放中,3已完成)')
    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='title', message='标题不能为空')
    def get_title(self):
        return self.title


    def validate_fields(self):
        self.get_title()




class Explanation_contentQueryModel(Explanation_contentModel):
    """
    讲解内容不分页查询模型
    """
    begin_create_time: Optional[str] = Field(default=None, description='开始创建时间')
    end_create_time: Optional[str] = Field(default=None, description='结束创建时间')
    begin_update_time: Optional[str] = Field(default=None, description='开始修改时间')
    end_update_time: Optional[str] = Field(default=None, description='结束修改时间')


@as_query
class Explanation_contentPageQueryModel(Explanation_contentQueryModel):
    """
    讲解内容分页查询模型
    """

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


class DeleteExplanation_contentModel(BaseModel):
    """
    删除讲解内容模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    explanation_content_ids: str = Field(description='需要删除的主键ID')
