Coverage for bc/kwai-bc-club/src/kwai_bc_club/domain/club_coach.py: 96%

23 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2024-01-01 00:00 +0000

1"""Module for defining a coach entity.""" 

2 

3from dataclasses import dataclass, field 

4from typing import ClassVar, Type 

5 

6from kwai_core.domain.entity import DataclassEntity 

7from kwai_core.domain.value_objects.identifier import IntIdentifier 

8from kwai_core.domain.value_objects.name import Name 

9from kwai_core.domain.value_objects.unique_id import UniqueId 

10 

11from kwai_bc_club.domain.member import MemberEntity 

12 

13 

14class ClubCoachIdentifier(IntIdentifier): 

15 """Identifier for a club coach.""" 

16 

17 

18@dataclass(kw_only=True, eq=False, slots=True, frozen=True) 

19class ClubCoachEntity(DataclassEntity): 

20 """A club coach entity. 

21 

22 Attributes: 

23 member: A coach is a member of the club. 

24 description: The description (bio) of the coach. 

25 diploma: The diploma of the coach. 

26 active: Whether the coach is active. 

27 remark: A remark about the coach. 

28 uuid: A public unique identifier of the coach. 

29 traceable_time: The creation and modification timestamp of the coach. 

30 """ 

31 

32 ID: ClassVar[Type] = ClubCoachIdentifier 

33 

34 member: MemberEntity 

35 description: str = "" 

36 diploma: str = "" 

37 head: bool = False 

38 active: bool = True 

39 remark: str = "" 

40 uuid: UniqueId = field(default_factory=UniqueId.generate) 

41 

42 @property 

43 def name(self) -> Name: 

44 """Return the name of the coach.""" 

45 return self.member.person.name 

46 

47 @property 

48 def member_uuid(self): 

49 """Return the uuid of associated member.""" 

50 return self.member.uuid