backend stuff for ingredients and nutritions AND FIXED MAGIC NUMBERS and fixed stevens and oskars problems
This commit is contained in:
parent
78e7f90024
commit
f9262d4046
2 changed files with 12 additions and 3 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue