initial commit
This commit is contained in:
1
back/app/entity/__init__.py
Normal file
1
back/app/entity/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .routes import router as entity_router
|
||||
BIN
back/app/entity/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
back/app/entity/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
back/app/entity/__pycache__/models.cpython-310.pyc
Normal file
BIN
back/app/entity/__pycache__/models.cpython-310.pyc
Normal file
Binary file not shown.
BIN
back/app/entity/__pycache__/routes.cpython-310.pyc
Normal file
BIN
back/app/entity/__pycache__/routes.cpython-310.pyc
Normal file
Binary file not shown.
BIN
back/app/entity/__pycache__/schemas.cpython-310.pyc
Normal file
BIN
back/app/entity/__pycache__/schemas.cpython-310.pyc
Normal file
Binary file not shown.
20
back/app/entity/models.py
Normal file
20
back/app/entity/models.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from enum import Enum
|
||||
from datetime import datetime
|
||||
from pydantic import Field
|
||||
|
||||
from beanie import Document
|
||||
|
||||
|
||||
class EntityType(str, Enum):
|
||||
individual = 'individual'
|
||||
corporation = 'corporation'
|
||||
institution = 'institution'
|
||||
|
||||
|
||||
class Entity(Document):
|
||||
_id: str
|
||||
type: EntityType
|
||||
name: str
|
||||
address: str
|
||||
created_at: datetime = Field(default=datetime.utcnow(), nullable=False)
|
||||
updated_at: datetime = Field(default_factory=datetime.utcnow, nullable=False)
|
||||
7
back/app/entity/routes.py
Normal file
7
back/app/entity/routes.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from ..core.routes import get_crud_router
|
||||
from .models import Entity
|
||||
from .schemas import EntityCreate, EntityRead, EntityUpdate
|
||||
|
||||
router = get_crud_router(Entity, EntityCreate, EntityRead, EntityUpdate)
|
||||
|
||||
|
||||
20
back/app/entity/schemas.py
Normal file
20
back/app/entity/schemas.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import uuid
|
||||
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .models import Entity, EntityType
|
||||
|
||||
|
||||
class EntityRead(Entity):
|
||||
pass
|
||||
|
||||
|
||||
class EntityCreate(BaseModel):
|
||||
type: EntityType
|
||||
name: str
|
||||
address: str
|
||||
|
||||
|
||||
class EntityUpdate(BaseModel):
|
||||
name: str
|
||||
Reference in New Issue
Block a user