-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMember.java
More file actions
134 lines (115 loc) · 4.21 KB
/
Member.java
File metadata and controls
134 lines (115 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package clap.server.domain.model.member;
import clap.server.adapter.outbound.persistense.entity.member.constant.MemberStatus;
import clap.server.domain.model.common.BaseTime;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
@Getter
@SuperBuilder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Member extends BaseTime {
private Long memberId;
private MemberInfo memberInfo;
private Member admin;
private Boolean kakaoworkNotificationEnabled;
private Boolean emailNotificationEnabled;
private String imageUrl;
private MemberStatus status;
private String password;
private Department department;
private Integer inProgressTaskCount;
private Integer inReviewingTaskCount;
public Member(MemberInfo memberInfo, Boolean emailNotificationEnabled, Boolean kakaoworkNotificationEnabled,
Member admin, String imageUrl, MemberStatus status, String password) {
this.memberInfo = memberInfo;
this.emailNotificationEnabled = emailNotificationEnabled;
this.kakaoworkNotificationEnabled = kakaoworkNotificationEnabled;
this.admin = admin;
this.imageUrl = imageUrl;
this.status = status;
this.password = password;
}
public static Member createMember(Member admin, MemberInfo memberInfo) {
return Member.builder()
.memberInfo(memberInfo)
.emailNotificationEnabled(false)
.kakaoworkNotificationEnabled(false)
.admin(admin)
.imageUrl(null)
.status(MemberStatus.PENDING)
.password(null)
.inReviewingTaskCount(null)
.inProgressTaskCount(null)
.build();
}
public void resetPassword(String newEncodedPassword) {
this.password = newEncodedPassword;
}
public void resetPasswordAndActivateMember(String newEncodedPassword) {
this.password = newEncodedPassword;
this.status = MemberStatus.ACTIVE;
this.emailNotificationEnabled = true;
this.kakaoworkNotificationEnabled = true;
}
public String getNickname() {
return memberInfo != null ? memberInfo.getNickname() : null;
}
public boolean isReviewer() {
return this.memberInfo != null && this.memberInfo.isReviewer();
}
public void changeToApproveRequested() {
this.status = MemberStatus.APPROVAL_REQUEST;
}
public void updateMemberInfo(String name, Boolean emailNotificationEnabled, Boolean kakaoWorkNotificationEnabled) {
this.memberInfo.updateName(name);
this.emailNotificationEnabled = emailNotificationEnabled;
this.kakaoworkNotificationEnabled = kakaoWorkNotificationEnabled;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public void softDelete() {
this.status = MemberStatus.DELETED;
}
public void updateKaKaoEnabled() {
if (!this.kakaoworkNotificationEnabled) {
this.kakaoworkNotificationEnabled = true;
}
else {
this.kakaoworkNotificationEnabled = false;
}
}
public void updateEmailEnabled() {
if (!this.emailNotificationEnabled) {
this.emailNotificationEnabled = true;
}
else {
this.emailNotificationEnabled = false;
}
}
public void register(Member admin) {
this.admin = admin;
}
public void incrementInProgressTaskCount() {
this.inProgressTaskCount++;
}
public void incrementInReviewingTaskCount() {
this.inReviewingTaskCount++;
}
public void decrementInProgressTaskCount() {
this.inProgressTaskCount--;
}
public void decrementInReviewingTaskCount() {
this.inReviewingTaskCount--;
}
public Integer getRemainingTasks(){
// 최종 회원 등록 전의 경우
if(this.getStatus().equals(MemberStatus.PENDING) || this.getStatus().equals(MemberStatus.APPROVAL_REQUEST)){
return null;
}
else return this.getInProgressTaskCount() + this.getInReviewingTaskCount();
}
}