Skip to content

Commit

Permalink
feat : 회원 도메인 개발
Browse files Browse the repository at this point in the history
  • Loading branch information
ohinhyuk committed Jul 28, 2023
1 parent d138683 commit fe87c9a
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 fe87c9a

Please sign in to comment.