from pydantic import BaseModel, Field


class ContractTemplateListQueryDTO(BaseModel):
    """合同模板列表查询参数。"""

    keyword: str | None = Field(None, description="关键词")
    category_id: int | None = Field(None, description="分类ID")
    category_name: str | None = Field(None, description="分类名称")
    region: str | None = Field(None, description="兼容保留字段：租户展示值/旧地区")
    tenant_code: str | None = Field(None, description="租户编码")
    file_format: str | None = Field(None, description="文件格式")
    is_featured: bool | None = Field(None, description="是否推荐")
    page: int = Field(1, ge=1, description="页码")
    page_size: int = Field(12, ge=1, le=200, description="分页大小")
    sort_by: str = Field("updated_at", description="排序字段")
    sort_order: str = Field("desc", description="排序方向")


class ContractTemplateSearchQueryDTO(BaseModel):
    """合同模板搜索参数。"""

    q: str = Field(..., min_length=1, description="搜索关键词")
    category_id: int | None = Field(None, description="分类ID")
    category_name: str | None = Field(None, description="分类名称")
    region: str | None = Field(None, description="兼容保留字段：租户展示值/旧地区")
    tenant_code: str | None = Field(None, description="租户编码")
    page: int = Field(1, ge=1, description="页码")
    page_size: int = Field(12, ge=1, le=200, description="分页大小")
    sort_by: str = Field("updated_at", description="排序字段")
    sort_order: str = Field("desc", description="排序方向")


class ContractTemplateCreateDTO(BaseModel):
    """合同模板上传参数。"""

    title: str = Field(..., min_length=1, max_length=200, description="模板标题")
    template_code: str = Field(..., min_length=1, max_length=50, description="模板编码")
    category_id: int = Field(..., description="分类ID")
    region: str | None = Field(None, description="兼容保留字段：所属租户展示值/旧地区")
    tenant_code: str | None = Field(None, description="所属租户编码")
    description: str | None = Field(None, description="模板简介")
    is_featured: bool = Field(False, description="是否推荐")
