Coverage for bc/kwai-bc-teams/src/kwai_bc_teams/domain/team_member.py: 91%
22 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 for defining the team member entity."""
3from dataclasses import dataclass
4from typing import ClassVar, Type
6from kwai_bc_club.domain.country import CountryEntity
7from kwai_bc_club.domain.value_objects import Birthdate, Gender, License
8from kwai_core.domain.entity import DataclassEntity
9from kwai_core.domain.value_objects.identifier import IntIdentifier
10from kwai_core.domain.value_objects.name import Name
11from kwai_core.domain.value_objects.traceable_time import TraceableTime
12from kwai_core.domain.value_objects.unique_id import UniqueId
15class MemberIdentifier(IntIdentifier):
16 """Identifier for a member."""
19@dataclass(kw_only=True, eq=False, slots=True, frozen=True)
20class MemberEntity(DataclassEntity):
21 """A member entity.
23 A member entity is an entity which holds specific information of a member
24 that can be used for a member of a team.
26 Attributes:
27 uuid: The uniqueid of the member.
28 name: The name of the member.
29 license: The license of the member.
30 birthdate: The birthdate of the member.
31 nationality: The nationality of the member.
32 gender: The gender of the member.
33 active_in_club: Is this member still active in the club?
34 """
36 ID: ClassVar[Type] = MemberIdentifier
38 uuid: UniqueId
39 name: Name
40 license: License
41 birthdate: Birthdate
42 nationality: CountryEntity
43 gender: Gender
44 active_in_club: bool = True
46 def __str__(self) -> str:
47 """Return a string of this entity."""
48 return f"{self.uuid} - {self.name}"
50 def __repr__(self) -> str:
51 """Return a representation of this entity."""
52 return f"<{self.__class__.__name__} id={self.id}, uuid={self.uuid}, name={self.name}>"
55@dataclass(kw_only=True, frozen=True, slots=True)
56class TeamMember:
57 """Represent a member of a team.
59 When active is False, it means the member is not active for the team it belongs
60 to.
61 """
63 active: bool = False
64 member: MemberEntity
65 traceable_time: TraceableTime = TraceableTime()