#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
模块名称：report_template.py
模块描述：功能测试报告模板配置 Pydantic 数据模型

作者：czj
创建日期：2026-08-13
最后修改：2026-08-13
"""

from typing import Dict, Optional
from pydantic import BaseModel, Field


class ReportTemplateCreateRequest(BaseModel):
    """创建报告模板请求"""
    name: str = Field(..., min_length=1, max_length=100, description="模板名称")
    description: Optional[str] = Field(None, max_length=200, description="模板描述")
    is_default: bool = Field(False, description="是否设为默认模板")
    config: Dict = Field(default_factory=dict, description="模板完整配置(章节开关/样式/默认值)")


class ReportTemplateUpdateRequest(BaseModel):
    """更新报告模板请求"""
    name: Optional[str] = Field(None, min_length=1, max_length=100, description="模板名称")
    description: Optional[str] = Field(None, max_length=200, description="模板描述")
    is_default: Optional[bool] = Field(None, description="是否设为默认模板")
    config: Optional[Dict] = Field(None, description="模板完整配置")


class ReportTemplateListItem(BaseModel):
    """报告模板列表项（不含 config 详情）"""
    id: int = Field(..., description="模板ID")
    name: str = Field(..., description="模板名称")
    description: Optional[str] = Field(None, description="模板描述")
    is_default: bool = Field(False, description="是否默认模板")
    updated_at: Optional[str] = Field(None, description="更新时间")


class ReportTemplateResponse(BaseModel):
    """报告模板完整响应"""
    id: int = Field(..., description="模板ID")
    name: str = Field(..., description="模板名称")
    description: Optional[str] = Field(None, description="模板描述")
    is_default: bool = Field(False, description="是否默认模板")
    config: Dict = Field(default_factory=dict, description="模板完整配置")
    created_at: Optional[str] = Field(None, description="创建时间")
    updated_at: Optional[str] = Field(None, description="更新时间")