This commit is contained in:
2026-02-27 22:44:02 +03:00
parent 55c3629868
commit c57a40b09a
14 changed files with 331 additions and 69 deletions
+23 -2
View File
@@ -6,8 +6,12 @@ from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker
from dutylog.infrastructure.database.config import create_engine, create_session_maker
from dutylog.infrastructure.database.dao.users_dao import UsersDAO
from dutylog.infrastructure.database.dao.hours_transactions_dao import HoursTransactionsDAO
from dutylog.infrastructure.database.dao.rooms_dao import RoomsDAO
from dutylog.infrastructure.database.dao.residents_dao import ResidentsDAO
from dutylog.infrastructure.database.repositories.users_repository import UsersRepository
from dutylog.infrastructure.database.repositories.hours_transactions_repository import HoursTransactionsRepository
from dutylog.infrastructure.database.repositories.rooms_repository import RoomsRepository
from dutylog.infrastructure.database.repositories.residents_repository import ResidentsRepository
from dutylog.infrastructure.utils.config import Config, load_config
@@ -43,6 +47,14 @@ class DAOProvider(Provider):
def get_hours_transactions_dao(self, session: AsyncSession) -> HoursTransactionsDAO:
return HoursTransactionsDAO(session)
@provide(scope=Scope.REQUEST)
def get_rooms_dao(self, session: AsyncSession) -> RoomsDAO:
return RoomsDAO(session)
@provide(scope=Scope.REQUEST)
def get_residents_dao(self, session: AsyncSession) -> ResidentsDAO:
return ResidentsDAO(session)
class RepositoryProvider(Provider):
@provide(scope=Scope.REQUEST)
@@ -53,9 +65,18 @@ class RepositoryProvider(Provider):
def get_hours_transactions_repository(
self,
transactions_dao: HoursTransactionsDAO,
users_dao: UsersDAO,
residents_dao: ResidentsDAO,
) -> HoursTransactionsRepository:
return HoursTransactionsRepository(transactions_dao, users_dao)
return HoursTransactionsRepository(transactions_dao, residents_dao)
@provide(scope=Scope.REQUEST)
def get_rooms_repository(self, rooms_dao: RoomsDAO) -> RoomsRepository:
return RoomsRepository(rooms_dao)
@provide(scope=Scope.REQUEST)
def get_residents_repository(self, residents_dao: ResidentsDAO) -> ResidentsRepository:
return ResidentsRepository(residents_dao)