46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from decimal import Decimal
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
|
|
|
|
class OutboundReleaseCellItem(BaseModel):
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
cellProductId: str = Field(..., min_length=1)
|
|
remark: Optional[str] = None
|
|
|
|
|
|
class OutboundReleaseQcMaterialItem(BaseModel):
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
materialId: str = Field(..., min_length=1)
|
|
qty: Decimal = Field(..., gt=0)
|
|
remark: Optional[str] = None
|
|
|
|
@field_validator("qty", mode="before")
|
|
@classmethod
|
|
def _coerce_qty(cls, v):
|
|
if v is None or v == "":
|
|
raise ValueError("用量必须大于0")
|
|
return v
|
|
|
|
|
|
class OutboundReleasePaperItem(BaseModel):
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
paperName: str = Field(..., min_length=1)
|
|
copies: int = Field(..., ge=1)
|
|
attachmentUrl: str = Field(..., min_length=1)
|
|
remark: Optional[str] = None
|
|
|
|
|
|
class OutboundReleaseMaterialSaveBody(BaseModel):
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
paperAttachments: Optional[str] = None
|
|
paperMaterials: List[OutboundReleasePaperItem] = Field(default_factory=list)
|
|
remark: Optional[str] = None
|
|
cells: List[OutboundReleaseCellItem] = Field(default_factory=list)
|
|
qcMaterials: List[OutboundReleaseQcMaterialItem] = Field(default_factory=list)
|