20 lines
296 B
Python
20 lines
296 B
Python
from dataclasses import dataclass
|
|
|
|
|
|
@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
|