aidress/app/schemas/dress.py
2025-03-21 17:06:54 +08:00

36 lines
1.5 KiB
Python

from pydantic import BaseModel, Field, HttpUrl
from typing import Optional
from datetime import datetime
from enum import Enum
from app.models.dress import GarmentType
class DressBase(BaseModel):
"""服装基础模型"""
name: str = Field(..., description="服装名称", example="夏季连衣裙")
image_url: Optional[str] = Field(None, description="服装图片URL", example="https://example.com/dress1.jpg")
garment_type: Optional[GarmentType] = Field(None, description="服装类型(上衣/下衣)", example="TOP_GARMENT")
description: Optional[str] = Field(None, description="服装描述", example="一款适合夏季穿着的轻薄连衣裙")
class DressCreate(DressBase):
"""创建服装的请求模型"""
pass
class DressUpdate(BaseModel):
"""更新服装的请求模型"""
name: Optional[str] = Field(None, description="服装名称", example="夏季连衣裙")
image_url: Optional[str] = Field(None, description="服装图片URL", example="https://example.com/dress1.jpg")
garment_type: Optional[GarmentType] = Field(None, description="服装类型(上衣/下衣)", example="TOP_GARMENT")
description: Optional[str] = Field(None, description="服装描述", example="一款适合夏季穿着的轻薄连衣裙")
class DressInDB(DressBase):
"""数据库中的服装模型"""
id: int
created_at: datetime
updated_at: datetime
class Config:
orm_mode = True
class DressResponse(DressInDB):
"""服装API响应模型"""
pass