28 lines
775 B
Python
28 lines
775 B
Python
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]
|