service_man/api/infrastructure/dependencies/repositories.py

28 lines
781 B
Python

from typing import Annotated
from fastapi import Depends
from sqlalchemy.ext.asyncio import AsyncSession
from api.domain.company.repository import CompanyRepository
from api.domain.user import UserRepository
from api.infrastructure.persistence.repositories.company_repository import (
SqlAlchemyCompanyRepository,
)
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)
def get_company_repository(
session: Annotated[AsyncSession, Depends(Stub(AsyncSession))],
) -> CompanyRepository:
return SqlAlchemyCompanyRepository(session)