Skip to content

Commit

Permalink
init file with export class
Browse files Browse the repository at this point in the history
  • Loading branch information
bozzelliandrea committed Jan 15, 2024
1 parent fe53595 commit 17aa912
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions abstract_data_layer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .category import CategoryRepository, Category

category = CategoryRepository()

__all__ = [Category, category]
12 changes: 6 additions & 6 deletions abstract_data_layer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
from typing import TypeVar, Generic, Protocol, List

ID = TypeVar('ID')
T = TypeVar('T')

class Entity(Generic[ID]):
def __init__(self, id: ID, create_date: datetime = datetime.now(), update_date: datetime = None):
self.id = id
self.create_date = create_date
self.update_date = update_date

class Entity(Protocol):
createDate: datetime
updateDate: datetime

T = TypeVar('T', bound=Entity)

class CRUD(Generic[T, ID]):

Expand All @@ -44,7 +45,6 @@ def create(self, obj: T) -> T:
def update(self, obj: T) -> T:
pass


class SortOrder(Enum):
ASC = 1
DESC = 2
Expand Down
3 changes: 1 addition & 2 deletions abstract_data_layer/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ def __init__(self, id: ID = None, name: str = None, description: str = None, col


class CategoryRepository(CRUD[Category[ID], ID], ABC):
def __init__(self):
pass
pass

0 comments on commit 17aa912

Please sign in to comment.