49 lines
979 B
Python
49 lines
979 B
Python
from pydantic import BaseModel
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
from .product import ProductResponse
|
|
|
|
|
|
class OrderItemCreate(BaseModel):
|
|
product_id: int
|
|
quantity: int
|
|
size: Optional[str] = None
|
|
color: Optional[str] = None
|
|
|
|
|
|
class OrderItemResponse(BaseModel):
|
|
id: int
|
|
product_id: int
|
|
quantity: int
|
|
price: float
|
|
size: Optional[str]
|
|
color: Optional[str]
|
|
product: ProductResponse
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class OrderCreate(BaseModel):
|
|
shipping_address: str
|
|
shipping_city: str
|
|
shipping_postal_code: str
|
|
shipping_country: str
|
|
|
|
|
|
class OrderResponse(BaseModel):
|
|
id: int
|
|
order_number: str
|
|
user_id: int
|
|
status: str
|
|
total_amount: float
|
|
shipping_address: str
|
|
shipping_city: str
|
|
shipping_postal_code: str
|
|
shipping_country: str
|
|
created_at: datetime
|
|
items: List[OrderItemResponse]
|
|
|
|
class Config:
|
|
from_attributes = True
|