feat: 도메인 정보 추가

This commit is contained in:
kimjunseo
2021-07-23 02:23:23 +09:00
parent ecd45ec0fd
commit 82c20475a0
2 changed files with 51 additions and 5 deletions

View File

@@ -1,33 +1,59 @@
package com.example.oauthspringsecurity.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.*;
@Entity
public class Member {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String oauthId;
private String name;
private String email;
private String imageUrl;
@Enumerated(EnumType.STRING)
private Role role;
protected Member() {
}
public Member(Long id, String name, String email, String imageUrl) {
public Member(String oauthId, String name, String email, String imageUrl, Role role) {
this(null, oauthId, name, email, imageUrl, role);
}
public Member(Long id, String oauthId, String name, String email, String imageUrl, Role role) {
this.id = id;
this.oauthId = oauthId;
this.name = name;
this.email = email;
this.imageUrl = imageUrl;
this.role = role;
}
public Member update(String name, String email, String imageUrl) {
this.name = name;
this.email = email;
this.imageUrl = imageUrl;
return this;
}
public String getRoleKey() {
return this.role.getKey();
}
public Long getId() {
return id;
}
public String getOauthId() {
return oauthId;
}
public String getName() {
return name;
}
@@ -39,4 +65,8 @@ public class Member {
public String getImageUrl() {
return imageUrl;
}
public Role getRole() {
return role;
}
}

View File

@@ -0,0 +1,16 @@
package com.example.oauthspringsecurity.domain;
public enum Role {
GUEST("ROLE_GUEST"),
USER("ROLE_USER");
private final String key;
Role(String key) {
this.key = key;
}
public String getKey() {
return key;
}
}