70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
"""Pydantic schemas - 商品轮播图"""
|
|
from pydantic import BaseModel, Field, ConfigDict
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
|
|
|
|
class ProductBannerBase(BaseModel):
|
|
"""商品轮播图基础字段"""
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
product_id: str = Field(..., description="商品ID", alias="productId")
|
|
media_type: str = Field(default="image", description="媒体类型:image-图片, video-视频", alias="mediaType")
|
|
file_url: str = Field(..., max_length=500, description="文件URL地址", alias="fileUrl")
|
|
thumbnail_url: Optional[str] = Field(None, max_length=500, description="缩略图URL", alias="thumbnailUrl")
|
|
sort_order: int = Field(default=0, description="排序", alias="sortOrder")
|
|
|
|
|
|
class ProductBannerCreate(ProductBannerBase):
|
|
"""创建商品轮播图请求"""
|
|
pass
|
|
|
|
|
|
class ProductBannerCreateBatch(BaseModel):
|
|
"""批量创建商品轮播图请求"""
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
items: List[ProductBannerCreate] = Field(..., description="轮播图列表")
|
|
|
|
|
|
class ProductBannerUpdate(BaseModel):
|
|
"""更新商品轮播图请求"""
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
media_type: Optional[str] = Field(None, alias="mediaType")
|
|
file_url: Optional[str] = Field(None, max_length=500, alias="fileUrl")
|
|
thumbnail_url: Optional[str] = Field(None, max_length=500, alias="thumbnailUrl")
|
|
sort_order: Optional[int] = Field(None, alias="sortOrder")
|
|
|
|
|
|
class ProductBannerSortItem(BaseModel):
|
|
"""单条排序项"""
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
id: str
|
|
sort_order: int = Field(..., alias="sortOrder")
|
|
|
|
|
|
class ProductBannerSortUpdate(BaseModel):
|
|
"""更新轮播图排序请求"""
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
items: List[ProductBannerSortItem] = Field(..., description="排序项列表")
|
|
|
|
|
|
class ProductBannerResponse(ProductBannerBase):
|
|
"""商品轮播图响应"""
|
|
model_config = ConfigDict(from_attributes=True, populate_by_name=True)
|
|
|
|
id: str
|
|
create_at: datetime
|
|
create_by: Optional[str] = None
|
|
create_name: Optional[str] = None
|
|
update_at: Optional[datetime] = None
|
|
|
|
|
|
class ProductBannerListResponse(BaseModel):
|
|
"""商品轮播图列表响应"""
|
|
list: List[ProductBannerResponse]
|
|
total: int
|