"""Repository مربوط به User."""
from __future__ import annotations

from sqlalchemy import select

from app.models.user import User
from app.repositories.base import BaseRepository


class UserRepository(BaseRepository[User]):
    model = User

    async def get_by_mobile(self, mobile: str) -> User | None:
        stmt = select(User).where(User.mobile == mobile)
        result = await self.session.execute(stmt)
        return result.scalar_one_or_none()

    async def get_by_keycloak_sub(self, keycloak_sub: str) -> User | None:
        stmt = select(User).where(User.keycloak_sub == keycloak_sub)
        result = await self.session.execute(stmt)
        return result.scalar_one_or_none()
