service_man/api/infrastructure/dependencies/usecases.py

36 lines
1.4 KiB
Python
Raw Normal View History

2024-03-31 04:18:41 +03:00
from typing import Annotated
from fastapi import Depends
from api.application.abstractions.uow import UnitOfWork
from api.application.protocols.password_hasher import PasswordHasher
2024-04-01 12:19:10 +03:00
from api.application.usecase.auth.create_user import CreateUser
2024-04-21 23:46:17 +03:00
from api.application.usecase.company.create_company import CreateCompany
from api.application.usecase.company.get_users_company import \
GetCompaniesByOwnerEmail
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.repository import UserRepository
2024-03-31 21:07:59 +03:00
from api.infrastructure.dependencies.stub import Stub
2024-03-31 04:18:41 +03:00
def provide_create_user(
2024-03-31 21:07:59 +03:00
user_repository: Annotated[UserRepository, Depends(Stub(UserRepository))],
uow: Annotated[UnitOfWork, Depends(Stub(UnitOfWork))],
password_hasher: Annotated[PasswordHasher, Depends(Stub(PasswordHasher))],
2024-03-31 04:18:41 +03:00
) -> CreateUser:
2024-04-21 23:46:17 +03:00
return CreateUser(
uow=uow, user_repository=user_repository, password_hasher=password_hasher
)
2024-04-10 00:33:31 +03:00
def provide_get_companies_by_email(
company_repository: Annotated[CompanyRepository, Depends(Stub(CompanyRepository))],
) -> GetCompaniesByOwnerEmail:
return GetCompaniesByOwnerEmail(company_repository=company_repository)
2024-04-21 23:46:17 +03:00
def provide_create_company(
company_repository: Annotated[CompanyRepository, Depends(Stub(CompanyRepository))]
) -> CreateCompany:
return CreateCompany(company_repository=company_repository)