-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMember.java
More file actions
105 lines (82 loc) · 2.95 KB
/
Member.java
File metadata and controls
105 lines (82 loc) · 2.95 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
package site.codemonster.comon.domain.auth.entity;
import site.codemonster.comon.domain.article.entity.Article;
import site.codemonster.comon.domain.teamApply.entity.TeamApply;
import site.codemonster.comon.domain.teamMember.entity.TeamMember;
import site.codemonster.comon.global.entityListeners.TimeStamp;
import jakarta.persistence.*;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import site.codemonster.comon.global.images.enums.ImageConstant;
@Entity
@Getter
public class Member extends TimeStamp {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String email;
private String memberUniqueId;
private String uuid;
private String role;
private String memberName;
private String imageUrl = ImageConstant.DEFAULT_MEMBER_PROFILE.getObjectKey();
private String description;
@OneToMany(mappedBy = "member")
private List<Article> articles = new ArrayList<>();
@OneToMany(mappedBy = "member")
private List<TeamMember> teamMembers = new ArrayList<>();
@OneToMany(mappedBy = "member")
private List<TeamApply> teamApplies = new ArrayList<>();
protected Member() {
}
public Member(String email, String memberUniqueId, String role) {
this.email = email;
this.memberUniqueId = memberUniqueId;
this.role = role;
this.uuid = UUID.randomUUID().toString();
}
public Member(String anonymousRole) {
this.id = -1L;
this.email = "anonymous";
this.memberUniqueId = "anonymous";
this.role = anonymousRole;
this.uuid = UUID.randomUUID().toString();
}
public void updateProfile(String memberName, String description, String imageUrl) {
if (memberName != null) {
this.memberName = memberName;
}
if (description != null) {
this.description = description;
}
if (imageUrl != null) {
this.imageUrl = imageUrl;
}
}
public void updateImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public boolean isMyUuid(String uuid){
return this.uuid.equals(uuid);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Member member = (Member) o;
return Objects.equals(email, member.email) && Objects.equals(memberUniqueId,
member.memberUniqueId) && Objects.equals(uuid, member.uuid) && Objects.equals(role,
member.role) && Objects.equals(memberName, member.memberName) && Objects.equals(
imageUrl, member.imageUrl) && Objects.equals(description, member.description);
}
@Override
public int hashCode() {
return Objects.hash(email, memberUniqueId, uuid, role, memberName, imageUrl, description);
}
}