Basic users and cities api
This commit is contained in:
0
app/domain/__init__.py
Normal file
0
app/domain/__init__.py
Normal file
32
app/domain/city.py
Normal file
32
app/domain/city.py
Normal file
@ -0,0 +1,32 @@
|
||||
from datetime import datetime
|
||||
from typing import Annotated
|
||||
|
||||
from litestar.contrib.sqlalchemy.base import UUIDBase
|
||||
from litestar.contrib.sqlalchemy.dto import SQLAlchemyDTO
|
||||
from litestar.dto import DTOConfig
|
||||
from sqlalchemy.orm import Mapped
|
||||
|
||||
from app.lib import service
|
||||
from app.lib.filter_repository import FilterRepository
|
||||
|
||||
|
||||
class City(UUIDBase):
|
||||
__tablename__ = "cities" # type: ignore[assignment]
|
||||
|
||||
name: Mapped[str]
|
||||
postal_code: Mapped[str]
|
||||
created_at: Mapped[datetime]
|
||||
modified_at: Mapped[datetime]
|
||||
|
||||
|
||||
class Repository(FilterRepository[City]):
|
||||
model_type = City
|
||||
|
||||
|
||||
class Service(service.Service[City]):
|
||||
repository_type = Repository
|
||||
|
||||
|
||||
write_config = DTOConfig(exclude={"id"})
|
||||
CityWriteDTO = SQLAlchemyDTO[Annotated[City, write_config]]
|
||||
CityReadDTO = SQLAlchemyDTO[City]
|
||||
0
app/domain/enums.py
Normal file
0
app/domain/enums.py
Normal file
32
app/domain/user.py
Normal file
32
app/domain/user.py
Normal file
@ -0,0 +1,32 @@
|
||||
from datetime import datetime
|
||||
from typing import Annotated
|
||||
|
||||
from litestar.contrib.sqlalchemy.base import UUIDBase
|
||||
from litestar.contrib.sqlalchemy.dto import SQLAlchemyDTO
|
||||
from litestar.dto import DTOConfig
|
||||
from sqlalchemy.orm import Mapped
|
||||
|
||||
from app.lib import service
|
||||
from app.lib.filter_repository import FilterRepository
|
||||
|
||||
|
||||
class User(UUIDBase):
|
||||
__tablename__ = "users" # type: ignore[assignment]
|
||||
|
||||
first_name: Mapped[str]
|
||||
last_name: Mapped[str]
|
||||
created_at: Mapped[datetime]
|
||||
modified_at: Mapped[datetime]
|
||||
|
||||
|
||||
class Repository(FilterRepository[User]):
|
||||
model_type = User
|
||||
|
||||
|
||||
class Service(service.Service[User]):
|
||||
repository_type = Repository
|
||||
|
||||
|
||||
write_config = DTOConfig(exclude={"id"})
|
||||
UserWriteDTO = SQLAlchemyDTO[Annotated[User, write_config]]
|
||||
UserReadDTO = SQLAlchemyDTO[User]
|
||||
Reference in New Issue
Block a user