backend stuff for ingredients and nutritions AND FIXED MAGIC NUMBERS and fixed stevens and oskars problems

This commit is contained in:
Aysegul Aydinlik 2025-12-05 00:12:53 +01:00
commit f9262d4046
2 changed files with 12 additions and 3 deletions

View file

@ -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")

View file

@ -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