add interface adapters for db
parent
6b2ab75561
commit
9ad635f8ec
|
|
@ -0,0 +1,8 @@
|
||||||
|
from typing import Optional, List
|
||||||
|
|
||||||
|
class CartDatabaseInterface:
|
||||||
|
def fetch_cart_items(self, user_id: int) -> Optional[List[dict]]:
|
||||||
|
"""
|
||||||
|
Abstract method to fetch cart items from the database for a given user ID.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError("fetch_cart_items must be implemented by a subclass")
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
#python imports
|
||||||
|
from typing import Optional, List
|
||||||
|
|
||||||
|
#dependency imports
|
||||||
|
from use_cases.cart_repository_interface import CartRepositoryInterface
|
||||||
|
from interface_adapters.cart_database_interface import CartDatabaseInterface
|
||||||
|
|
||||||
|
class CartRepository(CartRepositoryInterface):
|
||||||
|
def __init__(self, database_gateway: CartDatabaseInterface):
|
||||||
|
self.database_gateway = database_gateway
|
||||||
|
|
||||||
|
def fetch_cart_by_user_id(self, user_id: int) -> Optional[List[dict]]:
|
||||||
|
return self.database_gateway.fetch_cart_items(user_id)
|
||||||
Loading…
Reference in New Issue