"""Repositories."""
from __future__ import annotations
from uuid import UUID
from sqlalchemy import select
from app.repositories.base import TenantBaseRepository


from uuid import UUID

from sqlalchemy import select

from app.models.catalog import ServiceCategory
from app.repositories.base import TenantBaseRepository


class ServiceCategoryRepository(TenantBaseRepository[ServiceCategory]):
    model = ServiceCategory

    async def get_by_code(self, tenant_id: UUID, code: str) -> ServiceCategory | None:
        if not hasattr(self.model, "code"):
            return None
        stmt = select(self.model).where(
            self.model.tenant_id == tenant_id,
            self.model.code == code,
            self.model.is_deleted.is_(False),
        )
        result = await self.session.execute(stmt)
        return result.scalar_one_or_none()


from uuid import UUID

from sqlalchemy import select

from app.models.catalog import BeautyService
from app.repositories.base import TenantBaseRepository


class BeautyServiceRepository(TenantBaseRepository[BeautyService]):
    model = BeautyService

    async def get_by_code(self, tenant_id: UUID, code: str) -> BeautyService | None:
        if not hasattr(self.model, "code"):
            return None
        stmt = select(self.model).where(
            self.model.tenant_id == tenant_id,
            self.model.code == code,
            self.model.is_deleted.is_(False),
        )
        result = await self.session.execute(stmt)
        return result.scalar_one_or_none()
