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.filter_repository import FilterRepository


class Company(BigIntBase):
    __tablename__ = "vending_companies"  # type: ignore[assignment]

    caption: Mapped[str]
    address: Mapped[str]
    city: Mapped[str]
    phone: Mapped[str]
    enabled: Mapped[str]
    country_code: Mapped[str]
    external_id: Mapped[str]
    alive: Mapped[bool]


class Repository(FilterRepository[Company]):
    model_type = Company
    alive_flag = "alive"


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


write_config = DTOConfig(exclude={"id"})
CompanyWriteDTO = SQLAlchemyDTO[Annotated[Company, write_config]]
CompanyReadDTO = SQLAlchemyDTO[Company]
