From e427a26c0adc0a90fed58675711a3ec1041400cf Mon Sep 17 00:00:00 2001 From: binary_ho Date: Fri, 8 Mar 2024 17:59:03 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20GitHubResource=EB=A5=BC=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=ED=95=98=EB=8A=94=20Embedded=20=EA=B0=9D=EC=B2=B4=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20(#112)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../imhere/core/member/GitHubResource.java | 28 +++++++++++++++++++ .../binaryho/imhere/core/member/Member.java | 18 +++++++++--- 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 src/main/java/gdsc/binaryho/imhere/core/member/GitHubResource.java diff --git a/src/main/java/gdsc/binaryho/imhere/core/member/GitHubResource.java b/src/main/java/gdsc/binaryho/imhere/core/member/GitHubResource.java new file mode 100644 index 0000000..b10d2fa --- /dev/null +++ b/src/main/java/gdsc/binaryho/imhere/core/member/GitHubResource.java @@ -0,0 +1,28 @@ +package gdsc.binaryho.imhere.core.member; + +import javax.persistence.Column; +import javax.persistence.Embeddable; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Embeddable +@Getter +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class GitHubResource { + + @Column(unique = true, name = "git_hub_id", nullable = false) + private String id; + + @Column(name = "git_hub_handle", nullable = false) + private String handle; + + @Column(name = "git_hub_profile") + private String profile; + + protected void updateHandle(String gitHubHandle) { + this.handle = gitHubHandle; + } +} diff --git a/src/main/java/gdsc/binaryho/imhere/core/member/Member.java b/src/main/java/gdsc/binaryho/imhere/core/member/Member.java index f2e4809..70a0e06 100644 --- a/src/main/java/gdsc/binaryho/imhere/core/member/Member.java +++ b/src/main/java/gdsc/binaryho/imhere/core/member/Member.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import java.time.LocalDateTime; import javax.persistence.Column; +import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; @@ -27,8 +28,13 @@ public class Member { @Column(name = "member_id") private Long id; + // TODO : nullable false 조건 제거 @Column(unique = true, nullable = false) private String univId; + + @Embedded + private GitHubResource gitHubResource; + @Column(nullable = false) private String name; private String password; @@ -41,10 +47,6 @@ public class Member { @CreatedDate private LocalDateTime createdAt; - public String getRoleKey() { - return role.getKey(); - } - public static Member createMember(String univId, String name, String password, Role role) { Member member = new Member(); member.setUnivId(univId); @@ -53,4 +55,12 @@ public static Member createMember(String univId, String name, String password, R member.setRole(role); return member; } + + public void updateGitHubHandle(String gitHubHandle) { + this.gitHubResource.updateHandle(gitHubHandle); + } + + public String getRoleKey() { + return role.getKey(); + } }