36 lines
673 B
Python
36 lines
673 B
Python
from pydantic import BaseModel
|
|
from typing import Optional, List
|
|
from .product import ProductResponse
|
|
|
|
|
|
class CartItemCreate(BaseModel):
|
|
product_id: int
|
|
quantity: int = 1
|
|
size: Optional[str] = None
|
|
color: Optional[str] = None
|
|
|
|
|
|
class CartItemUpdate(BaseModel):
|
|
quantity: Optional[int] = None
|
|
|
|
|
|
class CartItemResponse(BaseModel):
|
|
id: int
|
|
product_id: int
|
|
quantity: int
|
|
size: Optional[str]
|
|
color: Optional[str]
|
|
product: ProductResponse
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class CartResponse(BaseModel):
|
|
id: int
|
|
user_id: int
|
|
items: List[CartItemResponse]
|
|
|
|
class Config:
|
|
from_attributes = True
|