Skip to content

Commit

Permalink
✨Feat: 유저 Entity와 즐찾음식, 팔로우유저 연관관계 설정 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
win-luck committed Oct 2, 2023
1 parent 3c9c3aa commit e9ae524
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/diareat/diareat/user/domain/User.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.diareat.diareat.user.domain;

import com.diareat.diareat.food.domain.FavoriteFood;
import com.diareat.diareat.food.domain.Food;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AccessLevel;
Expand Down Expand Up @@ -37,6 +38,12 @@ public class User {
@OneToMany(mappedBy = "user", cascade = {CascadeType.PERSIST, CascadeType.REMOVE}) // 유저가 탈퇴하면 촬영한 음식도 삭제
private List<Food> foods = new ArrayList<>();

@OneToMany(mappedBy = "user", cascade = {CascadeType.PERSIST, CascadeType.REMOVE}) // 유저가 탈퇴하면 즐겨찾기 음식도 삭제
private List<FavoriteFood> favoriteFoods = new ArrayList<>();

@OneToMany(mappedBy = "user") // 유저의 팔로우 목록
private List<User> followings = new ArrayList<>();

// 생성 메서드
public static User createUser(String name, String keyCode, int height, int weight, int gender, int age, BaseNutrition baseNutrition) {
User user = new User();
Expand Down

0 comments on commit e9ae524

Please sign in to comment.