Skip to content

Commit

Permalink
refactor: requirement를 embeddable로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook02 committed Feb 11, 2024
1 parent e6d056f commit 2d9ab25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
import com.gdschongik.gdsc.domain.common.model.BaseTimeEntity;
import com.gdschongik.gdsc.domain.requirement.domain.Requirement;
import com.gdschongik.gdsc.global.exception.CustomException;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Builder;
Expand Down Expand Up @@ -59,8 +56,7 @@ public class Member extends BaseTimeEntity {

private String univEmail;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(name = "requirement_id")
@Embedded
private Requirement requirement;

@Builder(access = AccessLevel.PRIVATE)
Expand Down Expand Up @@ -94,7 +90,7 @@ private Member(
}

public static Member createGuestMember(String oauthId) {
Requirement requirement = Requirement.createInstance();
Requirement requirement = Requirement.createRequirement();
return Member.builder()
.oauthId(oauthId)
.role(MemberRole.GUEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@

import static com.gdschongik.gdsc.domain.requirement.domain.RequirementStatus.*;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Embeddable;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Embeddable
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Requirement {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "requirement_id")
private Long id;

@Enumerated(EnumType.STRING)
private RequirementStatus univStatus;

Expand All @@ -41,7 +32,7 @@ private Requirement(
this.paymentStatus = paymentStatus;
}

public static Requirement createInstance() {
public static Requirement createRequirement() {
return Requirement.builder()
.univStatus(PENDING)
.discordStatus(PENDING)
Expand Down

0 comments on commit 2d9ab25

Please sign in to comment.