37 lines
1014 B
Python
37 lines
1014 B
Python
from typing import Annotated
|
|
|
|
from litestar.contrib.sqlalchemy.base import BigIntBase
|
|
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.company_owned_repository import CompanyOwnedRepository
|
|
|
|
|
|
class Machine_00300(BigIntBase):
|
|
__tablename__ = "machines" # type: ignore[assignment]
|
|
__table_args__ = {'extend_existing': True}
|
|
|
|
caption: Mapped[str]
|
|
enabled: Mapped[bool]
|
|
alive: Mapped[bool]
|
|
deleted: Mapped[bool]
|
|
external_id: Mapped[str]
|
|
owner_id: Mapped[int]
|
|
|
|
|
|
class Repository(CompanyOwnedRepository[Machine_00300]):
|
|
model_type = Machine_00300
|
|
alive_flag = "alive"
|
|
company_id_field = "owner_id"
|
|
|
|
|
|
class Service(service.Service[Machine_00300]):
|
|
repository_type = Repository
|
|
|
|
|
|
write_config = DTOConfig(exclude={"id"})
|
|
Machine_00300_WriteDTO = SQLAlchemyDTO[Annotated[Machine_00300, write_config]]
|
|
Machine_00300_ReadDTO = SQLAlchemyDTO[Machine_00300]
|