22 lines
359 B
Python
22 lines
359 B
Python
from dataclasses import dataclass
|
|
from typing import Optional
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class CartItemDTO:
|
|
product_id: int
|
|
name: str
|
|
quantity: int
|
|
price: int
|
|
|
|
@property
|
|
def total(self):
|
|
return self.price * self.quantity
|
|
|
|
|
|
@dataclass
|
|
class CartDTO:
|
|
items: list[CartItemDTO]
|
|
total: int
|
|
order_id: Optional[int] = None
|