47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
"""商品单位Schema"""
|
|
from typing import Optional, List
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class UnitBase(BaseModel):
|
|
"""单位基础Schema"""
|
|
name: str = Field(..., description="单位名称")
|
|
code: str = Field(..., description="单位编码")
|
|
is_active: bool = Field(True, description="是否启用")
|
|
sort_order: int = Field(0, description="排序字段,数值越小越靠前")
|
|
|
|
|
|
class UnitCreate(UnitBase):
|
|
"""创建单位"""
|
|
pass
|
|
|
|
|
|
class UnitUpdate(BaseModel):
|
|
"""更新单位"""
|
|
name: Optional[str] = Field(None, description="单位名称")
|
|
code: Optional[str] = Field(None, description="单位编码")
|
|
is_active: Optional[bool] = Field(None, description="是否启用")
|
|
sort_order: Optional[int] = Field(None, description="排序字段")
|
|
|
|
|
|
class UnitResponse(UnitBase):
|
|
"""单位响应"""
|
|
id: str
|
|
create_at: Optional[str] = None
|
|
create_by: Optional[str] = None
|
|
create_name: Optional[str] = None
|
|
update_at: Optional[str] = None
|
|
update_by: Optional[str] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class UnitListResponse(BaseModel):
|
|
"""单位列表响应"""
|
|
items: List[UnitResponse]
|
|
total: int
|
|
page: int
|
|
pageSize: int
|
|
totalPages: int
|