-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
86 lines (67 loc) · 2.08 KB
/
User.java
File metadata and controls
86 lines (67 loc) · 2.08 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
package app.dearobjet.backend.domain.user.entity;
import app.dearobjet.backend.domain.user.enums.Role;
import app.dearobjet.backend.domain.user.enums.UserStatus;
import jakarta.persistence.*;
import lombok.*;
@Entity
@Table(name = "users")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
public class User extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Long id;
@Column(unique = true)
private String email;
private String name;
@Column(unique = true)
private String phoneNumber;
@Column(name = "profile_image")
private String profileImage;
@Column(name = "sms_agreement")
private Boolean smsAgreement;
@Column(name = "marketing_agreement")
private Boolean marketingAgreement;
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Role role;
@Column(name = "profile_url")
private String profileUrl;
@Enumerated(EnumType.STRING)
@Column(name = "user_status", nullable = false)
private UserStatus userStatus;
// 카카오 단일
// @Column(name = "login_type")
// private String loginType; // EMAIL, KAKAO, NAVER, GOOGLE
@Column(name = "social_id")
private String socialId;
// 비즈니스 메서드
public void updateProfile(String name, String profileUrl) {
this.name = name;
this.profileUrl = profileUrl;
}
public void deactivate() {
this.userStatus = UserStatus.INACTIVE;
}
public void completeRegistration(
String name,
String email,
String phoneNumber,
Boolean smsAgreement,
Boolean marketingAgreement,
Role role
) {
if (this.role != Role.TEMP) {
throw new IllegalStateException("User already registered");
}
this.name = name;
this.email = email;
this.phoneNumber = phoneNumber;
this.smsAgreement = smsAgreement;
this.marketingAgreement = marketingAgreement;
this.role = role;
}
}