Coverage for bc/kwai-bc-club/src/kwai_bc_club/domain/member.py: 100%

20 statements  

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

1"""Module for defining the Member 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.person import PersonEntity 

12from kwai_bc_club.domain.value_objects import License, User 

13 

14 

15class MemberIdentifier(IntIdentifier): 

16 """Identifier for a member.""" 

17 

18 

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

20class MemberEntity(DataclassEntity): 

21 """A member entity. 

22 

23 Attributes: 

24 uuid: A unique id for the member. 

25 license: The license of the member. 

26 person: The related person entity. 

27 remark: A remark about the member. 

28 active: Is this member still member of the club? 

29 competition: Is this member participating in competitions? 

30 user: A related user. 

31 """ 

32 

33 ID: ClassVar[Type] = MemberIdentifier 

34 

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

36 license: License 

37 person: PersonEntity 

38 remark: str = "" 

39 active: bool = True 

40 competition: bool = False 

41 user: User | None = None 

42 

43 @property 

44 def name(self) -> Name: 

45 """Return the name of the member.""" 

46 return self.person.name