Skip to content

Commit

Permalink
Merge pull request #4 from HGU-WALAB/#3/memberDomain
Browse files Browse the repository at this point in the history
νšŒμ› 도메인 개발
  • Loading branch information
ohinhyuk authored Jul 28, 2023
2 parents d138683 + fe87c9a commit b8120ca
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/main/java/com/hackathonOne/hackathon/domain/Member.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,55 @@
package com.hackathonOne.hackathon.domain;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;

@Entity
@Getter @Setter
public class Member {

@Id @GeneratedValue
@Column(name="member_id")
private Long id;

private String name;

private String email;

@OneToMany(mappedBy="member", cascade = CascadeType.ALL)
private List<Allergy> allergies = new ArrayList<>();
@OneToMany(mappedBy="member", cascade = CascadeType.ALL)
private List<CanEat> canEats = new ArrayList<>();
@OneToMany(mappedBy="member", cascade = CascadeType.ALL)
private List<SpecialType> specialTypes = new ArrayList<>();

//== 연관관계 λ©”μ„œλ“œ ==//
// public void addCanEat(CanEat canEat){
// CanEats.add(canEat);
// CanEat.setMember(this);
// }
public void addAllergy(Allergy allergy){
Allergies.add(allergy);
Allergy.setMember(this);
}
public void addSpecialType(SpecialType specialType){
SpecialTypes.add(specialType);
SpecialType.setMember(this);
}

public static Member createMember(Member member, SpecialType... specialTypes, Allergy... allergies){

for(SpecialType specialType : specialTypes){
member.addSpecialType(specialType);
}

for(Allergy allergy : allergies){
member.addAllergy(allergy);
}

return member;
}

}

0 comments on commit b8120ca

Please sign in to comment.