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_00063(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_00063]):
    model_type = Machine_00063
    alive_flag = "alive"
    company_id_field = "owner_id"


class Service(service.Service[Machine_00063]):
    repository_type = Repository


write_config = DTOConfig(exclude={"id"})
Machine_00063_WriteDTO = SQLAlchemyDTO[Annotated[Machine_00063, write_config]]
Machine_00063_ReadDTO = SQLAlchemyDTO[Machine_00063]
