Working version
This commit is contained in:
0
app/domain/__init__.py
Normal file
0
app/domain/__init__.py
Normal file
27
app/domain/machine.py
Normal file
27
app/domain/machine.py
Normal file
@ -0,0 +1,27 @@
|
||||
from typing import Annotated
|
||||
|
||||
from litestar.contrib.sqlalchemy.base import BigIntBase
|
||||
from litestar.contrib.sqlalchemy.dto import SQLAlchemyDTO
|
||||
from litestar.contrib.sqlalchemy.repository import SQLAlchemyAsyncRepository
|
||||
from litestar.dto import DTOConfig
|
||||
from sqlalchemy.orm import Mapped
|
||||
|
||||
from app.lib import service
|
||||
|
||||
|
||||
class Machine(BigIntBase):
|
||||
__tablename__ = "machines"
|
||||
caption: Mapped[str]
|
||||
|
||||
|
||||
class Repository(SQLAlchemyAsyncRepository[Machine]):
|
||||
model_type = Machine
|
||||
|
||||
class Service(service.Service[Machine]):
|
||||
repository_type = Repository
|
||||
|
||||
|
||||
# write_config = DTOConfig(exclude={"created_at", "updated_at", "nationality"})
|
||||
write_config = DTOConfig()
|
||||
MachineWriteDTO = SQLAlchemyDTO[Annotated[Machine, write_config]]
|
||||
MachineReadDTO = SQLAlchemyDTO[Machine]
|
||||
Reference in New Issue
Block a user