Coverage for bc/kwai-bc-club/src/kwai_bc_club/get_coach.py: 100%
15 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
1"""Module that defines the use case 'Get Coach'."""
3from dataclasses import dataclass
5from kwai_core.domain.presenter import Presenter
6from kwai_core.domain.value_objects.unique_id import UniqueId
8from kwai_bc_club.domain.club_coach import ClubCoachEntity
9from kwai_bc_club.repositories.coach_repository import CoachRepository
12@dataclass(frozen=True, kw_only=True, slots=True)
13class GetCoachCommand:
14 """Input for the use case.
16 Attributes:
17 uuid: The unique id of the coach.
18 """
20 uuid: str
23class GetCoach:
24 """Use case 'Get Coach'."""
26 def __init__(
27 self,
28 coach_repo: CoachRepository,
29 presenter: Presenter[ClubCoachEntity],
30 ):
31 """Initialize the use case."""
32 self._coach_repo = coach_repo
33 self._presenter = presenter
35 async def execute(self, command: GetCoachCommand) -> None:
36 """Execute the use case."""
37 query = self._coach_repo.create_query().filter_by_uuid(
38 UniqueId.create_from_string(command.uuid)
39 )
40 coach = await self._coach_repo.get(query)
42 self._presenter.present(coach)