Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 2단계 - 리팩터링(메뉴) #225

Open
wants to merge 13 commits into
base: jordy-torvalds
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/main/java/kitchenpos/menus/tobe/domain/ToBeMenu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package kitchenpos.menus.tobe.domain;

import kitchenpos.menus.domain.MenuGroup;
import kitchenpos.menus.domain.MenuProduct;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;

@Table(name = "menu")
@Entity
public class ToBeMenu {
@Column(name = "id", columnDefinition = "binary(16)")
@Id
private UUID id;

@Column(name = "name", nullable = false)
private String name;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

용어사전, 모델링에서 사용한 워딩으로 통일해보는 것은 어떤가요?
이해관계자와 소통을 할 때는 displayedName 으로 소통하다가 실제 코드와 불일치로 인해 DDD 의 핵심인 전략적 설계가 희석되는 것 같아요


@Column(name = "price", nullable = false)
private BigDecimal price;

@ManyToOne(optional = false)
@JoinColumn(
name = "menu_group_id",
columnDefinition = "binary(16)",
foreignKey = @ForeignKey(name = "fk_menu_to_menu_group")
)
private MenuGroup menuGroup;

@Column(name = "displayed", nullable = false)
private boolean displayed;

@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(
name = "menu_id",
nullable = false,
columnDefinition = "binary(16)",
foreignKey = @ForeignKey(name = "fk_menu_product_to_menu")
)
private List<MenuProduct> menuProducts;

@Transient
private UUID menuGroupId;

protected ToBeMenu() {
}

}
21 changes: 21 additions & 0 deletions src/main/java/kitchenpos/menus/tobe/domain/ToBeMenuGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package kitchenpos.menus.tobe.domain;

import kitchenpos.common.values.Name;

import javax.persistence.*;
import java.util.UUID;

@Table(name = "menu_group")
@Entity
public class ToBeMenuGroup {
@Column(name = "id", columnDefinition = "binary(16)")
@Id
private UUID id;

@Embedded
private Name name;

protected ToBeMenuGroup() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package kitchenpos.menus.tobe.domain;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

public interface ToBeMenuGroupRepository {
ToBeMenuGroup save(ToBeMenuGroup menuGroup);

Optional<ToBeMenuGroup> findById(UUID id);

List<ToBeMenuGroup> findAll();
}

34 changes: 34 additions & 0 deletions src/main/java/kitchenpos/menus/tobe/domain/ToBeMenuProduct.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package kitchenpos.menus.tobe.domain;


import kitchenpos.products.domain.Product;

import javax.persistence.*;
import java.util.UUID;

@Table(name = "menu_product")
@Entity
public class ToBeMenuProduct {
@Column(name = "seq")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
private Long seq;

@ManyToOne(optional = false)
@JoinColumn(
name = "product_id",
columnDefinition = "binary(16)",
foreignKey = @ForeignKey(name = "fk_menu_product_to_product")
)
private Product product;

@Column(name = "quantity", nullable = false)
private long quantity;

@Transient
private UUID productId;

protected ToBeMenuProduct() {
}

}
18 changes: 18 additions & 0 deletions src/main/java/kitchenpos/menus/tobe/domain/ToBeMenuRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package kitchenpos.menus.tobe.domain;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

public interface ToBeMenuRepository {
ToBeMenu save(ToBeMenu menu);

Optional<ToBeMenu> findById(UUID id);

List<ToBeMenu> findAll();

List<ToBeMenu> findAllByIdIn(List<UUID> ids);

List<ToBeMenu> findAllByProductId(UUID productId);
}