Skip to content

Commit

Permalink
chore: 데이터 모델 구현 초기 수정(#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinheekim committed Apr 3, 2024
1 parent f947a38 commit 90119fc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import net.skhu.tastyinventory_be.domain.inventoryVolume.InventoryVolume;
import net.skhu.tastyinventory_be.domain.recipe.Recipe;

import java.util.HashSet;
import java.util.Set;
Expand All @@ -17,16 +18,21 @@ public class Inventory {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(length = 45)
private String name;

@Column(length = 45)
private String unit;

@OneToMany(mappedBy = "inventory", cascade = CascadeType.ALL, orphanRemoval = true)
@OneToMany(mappedBy = "inventory")
private Set<Recipe> recipes = new HashSet<>();

@OneToMany(mappedBy = "inventory")
private Set<InventoryVolume> inventoryVolumes = new HashSet<>();


@Builder
public Inventory(Long id, String name, String unit, Set<InventoryVolume> inventoryVolumes) {
this.id = id;
public Inventory(String name, String unit, Set<InventoryVolume> inventoryVolumes) {
this.name = name;
this.unit = unit;
this.inventoryVolumes = inventoryVolumes != null ? inventoryVolumes : new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,42 @@ public class InventoryVolume {
@Temporal(TemporalType.DATE)
private Date weekStart;

@Column(nullable = false)
private Integer friInventory;

@Column(nullable = false)
private Integer sunInventory;

@Column(nullable = false)
private Integer monOrder;

@Column(nullable = false)
private Integer tueOrder;

@Column(nullable = false)
private Integer wedOrder;

@Column(nullable = false)
private Integer thuOrder;

@Column(nullable = false)
private Integer friOrder;

@Column(nullable = false)
private Integer satOrder;

@Column(nullable = false)
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;
public InventoryVolume(Date weekStart, Integer friInventory, Integer sunInventory, Integer monOrder, Integer tueOrder, Integer wedOrder, Integer thuOrder, Integer friOrder, Integer satOrder, Integer sunOrder, Inventory inventory) {
this.weekStart = weekStart;
this.friInventory = friInventory;
this.sunInventory = sumInventory;
this.sunInventory = sunInventory;
this.monOrder = monOrder;
this.tueOrder = tueOrder;
this.wedOrder = wedOrder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public class Menu {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false)
private String name;

@OneToMany(mappedBy = "menu", cascade = CascadeType.ALL, orphanRemoval = true)
@OneToMany(mappedBy = "menu")
private Set<Recipe> recipes = new HashSet<>();

@Builder
public Menu(Long id, String name) {
this.id = id;
public Menu(String name) {
this.name = name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@
public class Recipe {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "menu_id")
private Menu menu;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "inventory_id")
@JoinColumn(name = "inventory_id", referencedColumnName = "id")
private Inventory inventory;

@Column(nullable = false)
private Integer usage; //재료 사용량

@Builder
public Recipe(Long id, Menu menu, Inventory inventory, Integer usage) {
this.id = id;
public Recipe(Menu menu, Inventory inventory, Integer usage) {
this.menu = menu;
this.inventory = inventory;
this.usage = usage;
Expand Down

0 comments on commit 90119fc

Please sign in to comment.