Skip to content

Commit

Permalink
feat : GitHubResource를 저장하는 Embedded 객체 구현 (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-ho committed Mar 8, 2024
1 parent 2a39544 commit e427a26
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
28 changes: 28 additions & 0 deletions src/main/java/gdsc/binaryho/imhere/core/member/GitHubResource.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
18 changes: 14 additions & 4 deletions src/main/java/gdsc/binaryho/imhere/core/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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();
}
}

0 comments on commit e427a26

Please sign in to comment.