diff --git a/src/main/java/net/skhu/tastyinventory_be/domain/inventory/Inventory.java b/src/main/java/net/skhu/tastyinventory_be/domain/inventory/Inventory.java new file mode 100644 index 0000000..7d97130 --- /dev/null +++ b/src/main/java/net/skhu/tastyinventory_be/domain/inventory/Inventory.java @@ -0,0 +1,34 @@ +package net.skhu.tastyinventory_be.domain.inventory; + +import jakarta.persistence.*; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.skhu.tastyinventory_be.domain.inventoryVolume.InventoryVolume; + +import java.util.HashSet; +import java.util.Set; + +@Getter +@NoArgsConstructor +@Entity +public class Inventory { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String name; + private String unit; + + @OneToMany(mappedBy = "inventory", cascade = CascadeType.ALL, orphanRemoval = true) + private Set inventoryVolumes = new HashSet<>(); + + + @Builder + public Inventory(Long id, String name, String unit, Set inventoryVolumes) { + this.id = id; + this.name = name; + this.unit = unit; + this.inventoryVolumes = inventoryVolumes != null ? inventoryVolumes : new HashSet<>(); + } +} diff --git a/src/main/java/net/skhu/tastyinventory_be/domain/inventory/InventoryRepository.java b/src/main/java/net/skhu/tastyinventory_be/domain/inventory/InventoryRepository.java new file mode 100644 index 0000000..cb25355 --- /dev/null +++ b/src/main/java/net/skhu/tastyinventory_be/domain/inventory/InventoryRepository.java @@ -0,0 +1,7 @@ +package net.skhu.tastyinventory_be.domain.inventory; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface InventoryRepository extends JpaRepository { + +} diff --git a/src/main/java/net/skhu/tastyinventory_be/domain/inventoryVolume/InventoryVolume.java b/src/main/java/net/skhu/tastyinventory_be/domain/inventoryVolume/InventoryVolume.java new file mode 100644 index 0000000..c953e39 --- /dev/null +++ b/src/main/java/net/skhu/tastyinventory_be/domain/inventoryVolume/InventoryVolume.java @@ -0,0 +1,53 @@ +package net.skhu.tastyinventory_be.domain.inventoryVolume; + +import jakarta.persistence.*; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.skhu.tastyinventory_be.domain.inventory.Inventory; + +import java.util.Date; + + +@Getter +@NoArgsConstructor +@Entity +public class InventoryVolume { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Temporal(TemporalType.DATE) + private Date weekStart; + + private Integer friInventory; + private Integer sunInventory; + private Integer monOrder; + private Integer tueOrder; + private Integer wedOrder; + private Integer thuOrder; + private Integer friOrder; + private Integer satOrder; + private Integer sunOrder; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "inventory_id") + private Inventory inventory; + + @Builder + public InventoryVolume(Long id, Date weekStart, Integer friInventory, Integer sumInventory, Integer monOrder, Integer tueOrder, Integer wedOrder, Integer thuOrder, Integer friOrder, Integer satOrder, Integer sunOrder, Inventory inventory) { + this.id = id; + this.weekStart = weekStart; + this.friInventory = friInventory; + this.sunInventory = sumInventory; + this.monOrder = monOrder; + this.tueOrder = tueOrder; + this.wedOrder = wedOrder; + this.thuOrder = thuOrder; + this.friOrder = friOrder; + this.satOrder = satOrder; + this.sunOrder = sunOrder; + this.inventory = inventory; + } +} diff --git a/src/main/java/net/skhu/tastyinventory_be/domain/inventoryVolume/InventoryVolumeRepository.java b/src/main/java/net/skhu/tastyinventory_be/domain/inventoryVolume/InventoryVolumeRepository.java new file mode 100644 index 0000000..3b68fa1 --- /dev/null +++ b/src/main/java/net/skhu/tastyinventory_be/domain/inventoryVolume/InventoryVolumeRepository.java @@ -0,0 +1,6 @@ +package net.skhu.tastyinventory_be.domain.inventoryVolume; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface InventoryVolumeRepository extends JpaRepository { +} diff --git a/src/main/java/net/skhu/tastyinventory_be/domain/menu/Menu.java b/src/main/java/net/skhu/tastyinventory_be/domain/menu/Menu.java new file mode 100644 index 0000000..bb7e47b --- /dev/null +++ b/src/main/java/net/skhu/tastyinventory_be/domain/menu/Menu.java @@ -0,0 +1,32 @@ +package net.skhu.tastyinventory_be.domain.menu; + +import jakarta.persistence.*; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.skhu.tastyinventory_be.domain.recipe.Recipe; + +import java.util.HashSet; +import java.util.Set; + +@Getter +@NoArgsConstructor +@Entity +public class Menu { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String name; + + @OneToMany(mappedBy = "menu", cascade = CascadeType.ALL, orphanRemoval = true) + private Set recipes = new HashSet<>(); + + @Builder + public Menu(Long id, String name) { + this.id = id; + this.name = name; + } + +} diff --git a/src/main/java/net/skhu/tastyinventory_be/domain/menu/MenuRepository.java b/src/main/java/net/skhu/tastyinventory_be/domain/menu/MenuRepository.java new file mode 100644 index 0000000..c72cd2e --- /dev/null +++ b/src/main/java/net/skhu/tastyinventory_be/domain/menu/MenuRepository.java @@ -0,0 +1,6 @@ +package net.skhu.tastyinventory_be.domain.menu; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MenuRepository extends JpaRepository { +} diff --git a/src/main/java/net/skhu/tastyinventory_be/domain/recipe/Recipe.java b/src/main/java/net/skhu/tastyinventory_be/domain/recipe/Recipe.java new file mode 100644 index 0000000..631442f --- /dev/null +++ b/src/main/java/net/skhu/tastyinventory_be/domain/recipe/Recipe.java @@ -0,0 +1,36 @@ +package net.skhu.tastyinventory_be.domain.recipe; + +import jakarta.persistence.*; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.skhu.tastyinventory_be.domain.inventory.Inventory; +import net.skhu.tastyinventory_be.domain.menu.Menu; + +@Getter +@NoArgsConstructor +@Entity +public class Recipe { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "menu_id") + private Menu menu; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "inventory_id") + private Inventory inventory; + + private Integer usage; //재료 사용량 + + @Builder + public Recipe(Long id, Menu menu, Inventory inventory, Integer usage) { + this.id = id; + this.menu = menu; + this.inventory = inventory; + this.usage = usage; + } + +} diff --git a/src/main/java/net/skhu/tastyinventory_be/domain/recipe/RecipeRepository.java b/src/main/java/net/skhu/tastyinventory_be/domain/recipe/RecipeRepository.java new file mode 100644 index 0000000..713f441 --- /dev/null +++ b/src/main/java/net/skhu/tastyinventory_be/domain/recipe/RecipeRepository.java @@ -0,0 +1,7 @@ +package net.skhu.tastyinventory_be.domain.recipe; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface RecipeRepository extends JpaRepository { + +}