from pydantic import BaseModel, Field class CategoryBase(BaseModel): """分类基础模型""" name: str = Field(..., max_length=100) color: str = Field(default="#FFB7C5", max_length=20) icon: str = Field(default="folder", max_length=50) class CategoryCreate(CategoryBase): """创建分类请求模型""" pass class CategoryUpdate(BaseModel): """更新分类请求模型""" name: str = Field(None, max_length=100) color: str = Field(None, max_length=20) icon: str = Field(None, max_length=50) class CategoryResponse(CategoryBase): """分类响应模型""" id: int class Config: from_attributes = True