-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
νμ λλ©μΈ κ°λ°
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/main/java/com/hackathonOne/hackathon/domain/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |