start
This commit is contained in:
parent
188ab620e0
commit
cc3d351bf2
40
src/main/java/com/example/hangry/Ingredient.java
Normal file
40
src/main/java/com/example/hangry/Ingredient.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package com.example.hangry;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Ingredient {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name; // Name der Zutat
|
||||||
|
|
||||||
|
public Ingredient() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ingredient(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter und Setter
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,7 @@
|
|||||||
package com.example.hangry;
|
package com.example.hangry;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.*;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import java.util.List;
|
||||||
import jakarta.persistence.GenerationType;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Recipe {
|
public class Recipe {
|
||||||
@ -14,13 +12,20 @@ public class Recipe {
|
|||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
|
private String category;
|
||||||
|
private String imageUrl;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
|
private List<RecipeIngredient> recipeIngredients;
|
||||||
|
|
||||||
public Recipe() {
|
public Recipe() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Recipe(String name, String description) {
|
public Recipe(String name, String description, String category, String imageUrl) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
this.category = category;
|
||||||
|
this.imageUrl = imageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getter und Setter
|
// Getter und Setter
|
||||||
@ -47,4 +52,28 @@ public class Recipe {
|
|||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategory(String category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImageUrl() {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageUrl(String imageUrl) {
|
||||||
|
this.imageUrl = imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RecipeIngredient> getRecipeIngredients() {
|
||||||
|
return recipeIngredients;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRecipeIngredients(List<RecipeIngredient> recipeIngredients) {
|
||||||
|
this.recipeIngredients = recipeIngredients;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
73
src/main/java/com/example/hangry/RecipeIngredient.java
Normal file
73
src/main/java/com/example/hangry/RecipeIngredient.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package com.example.hangry;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class RecipeIngredient {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "recipe_id", nullable = false)
|
||||||
|
private Recipe recipe;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "ingredient_id", nullable = false)
|
||||||
|
private Ingredient ingredient;
|
||||||
|
|
||||||
|
private String amount; // Menge, z. B. "200 g"
|
||||||
|
private String unit; // Einheit, z. B. "g", "ml", "Stück"
|
||||||
|
|
||||||
|
public RecipeIngredient() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipeIngredient(Recipe recipe, Ingredient ingredient, String amount, String unit) {
|
||||||
|
this.recipe = recipe;
|
||||||
|
this.ingredient = ingredient;
|
||||||
|
this.amount = amount;
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter und Setter
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Recipe getRecipe() {
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRecipe(Recipe recipe) {
|
||||||
|
this.recipe = recipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ingredient getIngredient() {
|
||||||
|
return ingredient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIngredient(Ingredient ingredient) {
|
||||||
|
this.ingredient = ingredient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(String amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user