Skip to content

Commit

Permalink
#22: WIP: feat: add basic review repositories and services
Browse files Browse the repository at this point in the history
  • Loading branch information
ReznikovRoman committed Jul 9, 2022
1 parent 849e1d2 commit c50ba11
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ugc/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import orjson
from dependency_injector import containers, providers

from ugc.domain import bookmarks, processors, progress
from ugc.domain import bookmarks, processors, progress, reviews
from ugc.domain.bookmarks.models import FilmBookmark
from ugc.domain.progress.models import UserFilmProgress
from ugc.helpers import sentinel
Expand Down Expand Up @@ -159,6 +159,15 @@ class Container(containers.DeclarativeContainer):
message_callback=bookmark_processor,
)

# Domain -> Reviews

review_repository = providers.Singleton(reviews.ReviewRepository)

review_service = providers.Factory(
reviews.ReviewService,
review_repository=review_repository,
)


def override_providers(container: Container) -> Container:
"""Перезаписывание провайдеров с помощью стабов."""
Expand Down
7 changes: 7 additions & 0 deletions src/ugc/domain/reviews/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .repositories import ReviewRepository
from .services import ReviewService

__all__ = [
"ReviewRepository",
"ReviewService",
]
5 changes: 5 additions & 0 deletions src/ugc/domain/reviews/repositories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ReviewRepository:
"""Репозиторий для работы с данными рецензий."""

async def create(self):
"""Создание рецензии."""
13 changes: 13 additions & 0 deletions src/ugc/domain/reviews/services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from .repositories import ReviewRepository


class ReviewService:
"""Сервис для работы с рецензиями."""

def __init__(self, review_repository: ReviewRepository) -> None:
assert isinstance(review_repository, ReviewRepository)
self._repository = review_repository

async def create_review(self):
"""Создание новой рецензии на фильм."""
await self._repository.create()

0 comments on commit c50ba11

Please sign in to comment.