service_man/api/infrastructure/persistence/repositories/user_repository.py

26 lines
762 B
Python
Raw Normal View History

2024-03-31 21:07:59 +03:00
from sqlalchemy import insert
2024-03-31 04:18:41 +03:00
from sqlalchemy.ext.asyncio import AsyncSession
from api.domain.user import User, UserRepository
2024-03-31 21:07:59 +03:00
from api.infrastructure.persistence.models.user import UserModel
2024-03-31 04:18:41 +03:00
class SqlAlchemyUserRepository(UserRepository):
def __init__(self, session: AsyncSession) -> None:
self.session = session
async def create_user(self, user: User) -> None:
2024-03-31 21:07:59 +03:00
stmt = insert(UserModel).values(
id=user.id.value,
name=user.name.value,
email=user.email.value,
hashed_password=user.hashed_password,
2024-03-31 21:07:59 +03:00
)
await self.session.execute(stmt)
2024-03-31 04:18:41 +03:00
async def get_user(self, filter: dict) -> User | None:
pass
async def get_users(self) -> list[User]:
return []