Skip to content

Commit

Permalink
[Server] 엔티티 수정(#47) (#48)
Browse files Browse the repository at this point in the history
* feat : recipe 엔티티 속성 추가

* feat : recipe 주재료 엔티티 추가
  • Loading branch information
Due-IT authored Sep 26, 2024
1 parent 910b925 commit c6e2093
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.sundaegukbap.banchango.ingredient.domain;

import com.sundaegukbap.banchango.recipe.domain.Recipe;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name="recipe_main_ingredients")
public class RecipeMainIngredient {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="recipe_id")
private Recipe recipe;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="ingredient_id")
private Ingredient ingredient;

@Builder
public RecipeMainIngredient(Long id, Recipe recipe, Ingredient ingredient) {
this.id = id;
this.recipe = recipe;
this.ingredient = ingredient;
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.sundaegukbap.banchango.recipe.domain;

import com.sundaegukbap.banchango.bookmark.domain.RecipeBookmark;
import com.sundaegukbap.banchango.ingredient.domain.Ingredient;
import com.sundaegukbap.banchango.ingredient.domain.RecipeRequiringIngredient;
import com.sundaegukbap.banchango.user.domain.User;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand All @@ -25,6 +24,7 @@ public class Recipe {
private Long id;
@NotNull
private String name;
private String bestName;
@NotNull
@Column(length=2048)
private String introduction;
Expand All @@ -40,16 +40,24 @@ public class Recipe {
@NotNull
@Enumerated(EnumType.STRING)
private Difficulty difficulty;
private String bySort;
private String byIngredient;
private String bySituation;

@Builder
public Recipe(Long id, String name, String introduction, String image1, String link, int servings, int cookingTime, Difficulty difficulty) {
public Recipe(Long id, String name, String bestName, String introduction, String image1, String image2, String link, int servings, int cookingTime, Difficulty difficulty, String bySort, String byIngredient, String bySituation) {
this.id = id;
this.name = name;
this.bestName = bestName;
this.introduction = introduction;
this.image1 = image1;
this.image2 = image2;
this.link = link;
this.servings = servings;
this.cookingTime = cookingTime;
this.difficulty = difficulty;
this.bySort = bySort;
this.byIngredient = byIngredient;
this.bySituation = bySituation;
}
}

0 comments on commit c6e2093

Please sign in to comment.