diff --git a/commons/src/main/java/commons/Ingredient.java b/commons/src/main/java/commons/Ingredient.java index 743fd20..f224f2f 100644 --- a/commons/src/main/java/commons/Ingredient.java +++ b/commons/src/main/java/commons/Ingredient.java @@ -1,12 +1,12 @@ package commons; +import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; - @Entity public class Ingredient { @@ -20,10 +20,17 @@ public class Ingredient { @GeneratedValue(strategy = GenerationType.AUTO) public long id; + @Column(name = "name", nullable = false, unique = true) public String name; + + @Column(name = "protein", nullable = false) public double proteinPer100g; + + @Column(name = "fat", nullable = false) public double fatPer100g; + + @Column(name = "carbs", nullable = false) public double carbsPer100g; @SuppressWarnings("unused") diff --git a/commons/src/main/java/commons/RecipeIngredient.java b/commons/src/main/java/commons/RecipeIngredient.java index f9062a6..c94d8dd 100644 --- a/commons/src/main/java/commons/RecipeIngredient.java +++ b/commons/src/main/java/commons/RecipeIngredient.java @@ -14,10 +14,12 @@ public class RecipeIngredient { @GeneratedValue(strategy = GenerationType.IDENTITY) public Long id; + // which recipe is used @ManyToOne(optional = false) @JoinColumn(name = "recipe_id") public Recipe recipe; + //which ingredient is used @ManyToOne(optional = false) @JoinColumn(name = "ingredient_id") public Ingredient ingredient; @@ -35,12 +37,12 @@ public class RecipeIngredient { public RecipeIngredient(Recipe recipe, //which recipe Ingredient ingredient, // which ingredient double amount, // the amount - String unitName) { //gram liter etc + String unit) { //gram liter etc //store it im tha field this.recipe = recipe; this.ingredient = ingredient; this.amount = amount; - this.unitName = unitName; + this.unitName = unit; } // Convert unitName to Unit object so java can read it