Files
zkxw/backend/app/schemas/product_parameter_value.py
T
2026-05-12 16:35:07 +08:00

76 lines
2.2 KiB
Python

"""Pydantic schemas - 商品参数值"""
from pydantic import BaseModel, Field, ConfigDict
from typing import Optional, List
from datetime import datetime
class ProductParameterValueBase(BaseModel):
"""商品参数值基础字段"""
model_config = ConfigDict(populate_by_name=True)
product_id: str = Field(..., description="商品ID", alias="productId")
parameter_id: str = Field(..., description="参数ID", alias="parameterId")
param_value: Optional[str] = Field(None, description="参数值", alias="paramValue")
class ProductParameterValueCreate(ProductParameterValueBase):
"""创建商品参数值请求"""
pass
class ProductParameterValueUpdate(BaseModel):
"""更新商品参数值请求"""
model_config = ConfigDict(populate_by_name=True)
param_value: Optional[str] = Field(None, description="参数值", alias="paramValue")
class ProductParameterValueBatchSave(BaseModel):
"""批量保存商品参数值请求"""
model_config = ConfigDict(populate_by_name=True)
product_id: str = Field(..., description="商品ID", alias="productId")
values: List[ProductParameterValueCreate] = Field(..., description="参数值列表")
class ProductParameterValueResponse(BaseModel):
"""商品参数值响应"""
id: str
product_id: str
parameter_id: str
parameter_name: Optional[str] = None
parameter_code: Optional[str] = None
param_type: Optional[str] = None
param_value: Optional[str] = None
sort_order: int
create_at: datetime
create_by: Optional[str] = None
create_name: Optional[str] = None
update_at: Optional[datetime] = None
class Config:
from_attributes = True
class ProductParameterValueListResponse(BaseModel):
"""商品参数值列表响应"""
list: List[ProductParameterValueResponse]
total: int
class ProductParameterValueWithParameterResponse(BaseModel):
"""带参数信息的商品参数值响应"""
id: str
product_id: str
parameter_id: str
parameter_name: str
parameter_code: str
param_type: str
options: Optional[str] = None
placeholder: Optional[str] = None
param_value: Optional[str] = None
sort_order: int
class Config:
from_attributes = True