-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMember.java
More file actions
129 lines (96 loc) · 3.59 KB
/
Member.java
File metadata and controls
129 lines (96 loc) · 3.59 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
package fitfit.domain.member.entity;
import fitfit.global.entity.BaseEntity;
import fitfit.global.enums.Gender;
import fitfit.global.enums.MemberStatus;
import fitfit.global.enums.Provider;
import fitfit.global.enums.Style;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Entity
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Getter
@DynamicInsert
@DynamicUpdate
public class Member extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "member_id")
private Long id;
@Column(length = 25, nullable = false)
private String name; // 실제 이름
@Column(length = 25, nullable = false)
private String nickname; // 앱 자체 닉네임(중복 확인 필요)
private String email; //카카오 가입 시 아이디(이메일)
@Column(length = 255)
private String profileImgUrl; // 프로필 사진
@Enumerated(EnumType.STRING)
@Column(length = 10, nullable = false, updatable = false)
private Provider provider;
@Column(length = 255, nullable = false)
private String providerId;
@Enumerated(EnumType.STRING)
private Gender gender;
@Column(length = 25, nullable = false)
private String phoneNumber;
@Column(length = 25, nullable = false)
private String height;
@Column(length = 25, nullable = false)
private String weight;
@Column(length = 255)
private String fullBodyImgUrl; // 전신 사진
private LocalDate birth;
@Enumerated(EnumType.STRING)
@Column(length = 10, nullable = false)
private MemberStatus status; // 회원 가입 상태
@Enumerated(EnumType.STRING)
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "member_preferred_style",
joinColumns = @JoinColumn(name = "member_id"))
@Column(name = "style_name", length = 25)
private List<Style> preferredStyle;
private LocalDateTime inactiveAt;
private Integer point;
private Integer clean_index;
public void updateNickname(String nickname) {
this.nickname = nickname;
}
public void updateName(String name) {this.name = name;}
public void updateBirth(LocalDate birth) {
this.birth = birth;
}
public void updateGender(Gender gender) {
this.gender = gender;
}
public void updateProfileImgUrl(String profileImgUrl) {
this.profileImgUrl = profileImgUrl;
}
public void updateHeight(String height) {this.height = height;}
public void updateWeight(String weight) {this.weight = weight;}
public void updatePhoneNumber(String phoneNumber) {this.phoneNumber = phoneNumber;}
public void updatePreferredStyle(List<Style> newStyleList) {
if (this.preferredStyle == null) {
this.preferredStyle = new ArrayList<>();
} else {
this.preferredStyle.clear();
}
// 2. 새 리스트가 null이 아니고 비어있지 않다면, 모든 요소를 추가합니다.
if (newStyleList != null && !newStyleList.isEmpty()) {
this.preferredStyle.addAll(newStyleList);
}
}
public void updateFullBodyImgUrl(String fullBodyImgUrl) {this.fullBodyImgUrl = fullBodyImgUrl;}
public void updateStatus(MemberStatus status) {
this.status = status;
if (status == MemberStatus.INACTIVE) {
this.inactiveAt = LocalDateTime.now(); // 시간 업데이트
}
}
}