service_man/api/infrastructure/dependencies/repositories.py

28 lines
781 B
Python
Raw Normal View History

2024-03-31 04:18:41 +03:00
from typing import Annotated
from fastapi import Depends
from sqlalchemy.ext.asyncio import AsyncSession
2024-04-10 00:33:31 +03:00
from api.domain.company.repository import CompanyRepository
2024-03-31 04:18:41 +03:00
from api.domain.user import UserRepository
2024-04-10 00:33:31 +03:00
from api.infrastructure.persistence.repositories.company_repository import (
SqlAlchemyCompanyRepository,
)
2024-03-31 04:18:41 +03:00
from api.infrastructure.persistence.repositories.user_repository import (
SqlAlchemyUserRepository,
)
from .stub import Stub
def get_user_repository(
session: Annotated[AsyncSession, Depends(Stub(AsyncSession))],
) -> UserRepository:
return SqlAlchemyUserRepository(session)
2024-04-10 00:33:31 +03:00
def get_company_repository(
session: Annotated[AsyncSession, Depends(Stub(AsyncSession))],
) -> CompanyRepository:
return SqlAlchemyCompanyRepository(session)