34 lines
671 B
Python
34 lines
671 B
Python
|
|
from pydantic import BaseModel
|
||
|
|
from typing import Optional
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
|
||
|
|
class ProductCreate(BaseModel):
|
||
|
|
sku: str
|
||
|
|
name: str
|
||
|
|
description: Optional[str] = None
|
||
|
|
category: Optional[str] = None
|
||
|
|
unit: str = "件"
|
||
|
|
cost_price: float = 0
|
||
|
|
sale_price: float = 0
|
||
|
|
min_stock: int = 0
|
||
|
|
max_stock: int = 1000
|
||
|
|
|
||
|
|
|
||
|
|
class ProductResponse(BaseModel):
|
||
|
|
id: int
|
||
|
|
sku: str
|
||
|
|
name: str
|
||
|
|
description: Optional[str]
|
||
|
|
category: Optional[str]
|
||
|
|
unit: str
|
||
|
|
cost_price: float
|
||
|
|
sale_price: float
|
||
|
|
min_stock: int
|
||
|
|
max_stock: int
|
||
|
|
is_active: bool
|
||
|
|
created_at: datetime
|
||
|
|
|
||
|
|
class Config:
|
||
|
|
from_attributes = True
|