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

๐Ÿš€ 3๋‹จ๊ณ„ - ๋ฆฌํŒฉํ„ฐ๋ง(๋งค์žฅ ์‹์‚ฌ ์ฃผ๋ฌธ) #322

Open
wants to merge 42 commits into
base: hoa0217
Choose a base branch
from

Conversation

hoa0217
Copy link

@hoa0217 hoa0217 commented Jun 21, 2024

์•ˆ๋…•ํ•˜์„ธ์š” ๋ฆฌ๋ทฐ์–ด๋‹˜.
๋งค์žฅ ์‹์‚ฌ ์ฃผ๋ฌธ ๋ฆฌํŒฉํ† ๋ง ์™„๋ฃŒํ•˜์—ฌ PR ์˜ฌ๋ฆฝ๋‹ˆ๋‹ค.
tobe ํŒจํ‚ค์ง€๋ฅผ ๋งŒ๋“ค์–ด์„œ OrderTable, StoreOrder๋ฅผ ์ˆ˜์ •ํ•œ ํ›„ application ๊ณ„์ธต๊นŒ์ง€ ์ˆ˜์ •์™„๋ฃŒํ•˜์˜€์Šต๋‹ˆ๋‹ค.

common ํŒจํ‚ค์ง€์— Order๋ผ๋Š” abstract class๋ฅผ ๋งŒ๋“ค์–ด์„œ ์ด๋ฅผ ์ƒ์†๋ฐ›์•„ ๊ฐ ์ฃผ๋ฌธ, ๋ฐฐ๋‹ฌ, ํฌ์žฅ Order ์—”ํ‹ฐํ‹ฐ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ•ด๋ณด๋ คํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ Menu๋ฆฌํŒฉํ† ๋ง์˜ ํ•„์š”์„ฑ์ด ๋Š๊ปด์ ธ ์•„๋ž˜์™€ ๊ฐ™์ด ๊ฐœ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค.

  • MenuProduct์— Price ํ”„๋กœํผํ‹ฐ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์ดํ•ฉ๊ณ„์‚ฐ์˜ ์ฑ…์ž„์„ MenuProduct๊ฐ€ ๊ฐ€์ง€๊ฒŒ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • MenuProductSerivce์— ๋‚˜์™€์žˆ๋Š” ๋น„์ง€๋‹ˆ์Šค๋กœ์ง์„ MenuProduct๋กœ ์˜ฎ๊ธด ํ›„ ์ œ๊ฑฐํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

hoa0217 added 30 commits June 19, 2024 02:09
- JPA Entity์—๋Š” ๋ถ™์ผ ์ˆ˜ ์—†๋‹ค.
- MenuProducts๋Š” MenuPrice๋ฅผ ๋ชฐ๋ผ๋„ ๋œ๋‹ค. ์˜์กด์„ฑ ์ œ๊ฑฐ.
- ํ•ด๋‹น ์ˆ˜๋Ÿ‰์€ ๋ฉ”๋‰ด์— ๋Œ€ํ•œ ์ˆ˜๋Ÿ‰์ด ์•„๋‹Œ, ๋ฉ”๋‰ด์ƒํ’ˆ์•ˆ์— ์ƒํ’ˆ์— ๋Œ€ํ•œ ์ˆ˜๋Ÿ‰์ด๋‹ค.
- ์ฃผ๋ฌธํด๋ž˜์Šค๋ฅผ ์ƒ์†๋ฐ›์œผ๋ฉฐ ๋งค์žฅ์ฃผ๋ฌธ์šฉ ๋น„์ง€๋‹ˆ์Šค๋กœ์ง์„ ๊ฐ–๋Š”๋‹ค.
- dto์— ์žˆ๋Š” ๋ถˆ๋ณ€์‹ ๊ฒ€์ฆ์„ ๋„๋ฉ”์ธ์œผ๋กœ ์˜ฎ๊ธด๋‹ค.
- dto์— ์žˆ๋Š” ๋ถˆ๋ณ€์‹ ๊ฒ€์ฆ์„ ๋„๋ฉ”์ธ์œผ๋กœ ์˜ฎ๊ธด๋‹ค.
Copy link

@liquidjoo liquidjoo left a comment

Choose a reason for hiding this comment

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

์•ˆ๋…•ํ•˜์„ธ์š” ์ •ํ™”๋‹˜ :)
3๋‹จ๊ณ„ ๋ฏธ์…˜ ์ž˜ํ•ด์ฃผ์…จ์–ด์š”
๋ช‡ ๊ฐ€์ง€ ์ฝ”๋ฉ˜ํŠธ ๋‚จ๊ฒผ์Šต๋‹ˆ๋‹ค
ํ™•์ธํ•˜๊ณ  ๋‹ค์‹œ ์š”์ฒญํ•ด ์ฃผ์„ธ์š” ๐Ÿ™‡

Comment on lines 35 to 47
private void validateMenuProducts(List<MenuProduct> menuProducts, List<Product> products) {
if (menuProducts == null || products == null) {
throw new IllegalArgumentException();
}

if (products.size() != menuProducts.size()) {
throw new IllegalArgumentException();
}

if (menuProducts.isEmpty()) {
throw new IllegalArgumentException();
}
}

Choose a reason for hiding this comment

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

๋‘˜ ์ด์ƒ์˜ ๋„๋ฉ”์ธ์ด ์—ฎ์ธ๋‹ค๋ฉด ๋„๋ฉ”์ธ ์„œ๋น„์Šค๋ฅผ ํ™œ์šฉํ•ด ๋ณด์•„๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™๋„ค์š” :)

Copy link
Author

Choose a reason for hiding this comment

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

๋„๋ฉ”์ธ ์„œ๋น„์Šค ๋„์ถœํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค!

Comment on lines 63 to 64
public Stream<MenuProduct> stream() {
return menuProducts.stream();

Choose a reason for hiding this comment

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

Stream ์œผ๋กœ ๋ฐ˜ํ™˜ํ•œ ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?
Stream ์œผ๋กœ ๋ฐ˜ํ™˜ ์‹œ ์–ด๋–ค ์žฅ๋‹จ์ ์ด ์žˆ์„๊นŒ์š”?

Copy link
Author

Choose a reason for hiding this comment

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

์žฅ์ ์œผ๋กœ Stream์œผ๋กœ ๋ฐ˜ํ™˜ ์‹œ getter๋ฅผ ์“ฐ์ง€์•Š๊ณ  ์ผ๊ธ‰์ปฌ๋ ‰์…˜์„ ํƒ์ƒ‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค~
๋‹จ์ ์œผ๋กœ๋Š”.. for๋ฌธ์„ ๋Œ๋ฆฌ๋Š” ๊ฒƒ๋ณด๋‹ค ์„ฑ๋Šฅ์ด ์•ˆ์ข‹์œผ๋ ค๋‚˜์š” ใ…Žใ…Ž ๋˜ํ•œ ๋””๋ฒ„๊น…์ด ์–ด๋ ค์šธ ์ˆ˜ ์žˆ๊ฒ ๋„ค์š”!
์ผ๋‹จ Iterable์„ ๊ตฌํ˜„ํ–ˆ์œผ๋‹ˆ ํ•ด๋‹น ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋„๋ก ์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

ํ˜น ์ œ๊ฐ€ ๋ชจ๋ฅด๋Š” ๋ถ€๋ถ„์ด ์žˆ๋‹ค๋ฉด ์กฐ์–ธ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

Comment on lines 23 to 31
public List<UUID> getMenuIds() {
return orderLineItems.stream().map(OrderLineItemRequest::getMenuId).toList();
}

public List<OrderLineItem> toOrderLineItems(List<Menu> menus, OrderType orderType) {
return orderLineItems.stream()
.map(orderLineItem -> orderLineItem.toStore(findMenu(menus, orderLineItem),
orderType)).toList();
}

Choose a reason for hiding this comment

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

๊ฐœ์ธ์ ์œผ๋ก  Dto ์—์„  ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ์ตœ๋Œ€ํ•œ ๋ฐฐ์ œํ•˜๋Š” ํŽธ์ธ๋ฐ์š” :)
์ €์˜ ์ƒ๊ฐ์€ Dto ๋Š” ๊ฐ์ฒด๋ผ๊ธฐ ๋ณด๋‹จ ๋ฐ์ดํ„ฐ ์ „๋‹ฌ์„ ํ•ด์ฃผ๋Š” ๊ตฌ์กฐ์ฒด์— ๊ฐ€๊น๋‹ค๊ณ  ์ƒ๊ฐํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค
์ •ํ™”๋‹˜์€ ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹œ๋‚˜์š”?

Copy link
Author

@hoa0217 hoa0217 Jul 1, 2024

Choose a reason for hiding this comment

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

๋งž์Šต๋‹ˆ๋‹ค. DTO๋Š” ๋ฐ์ดํ„ฐ ์ „๋‹ฌ์šฉ ๊ฐ์ฒด์ด์ง€ ๋น„์ง€๋‹ˆ์Šค๋กœ์ง์€ ๋„๋ฉ”์ธ๊ณ„์ธต์—์„œ ๊ฐ€์ ธ์•ผํ•ฉ๋‹ˆ๋‹ค. ๋น„์ง€๋‹ˆ์Šค๋กœ์ง์€ ๋„๋ฉ”์ธ์œผ๋กœ ์—”ํ‹ฐํ‹ฐ ์ƒ์„ฑ ์ฑ…์ž„์€ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์œผ๋กœ ์˜ฎ๊ธฐ๊ฒ ์Šต๋‹ˆ๋‹ค!

Comment on lines 33 to 36
private Menu findMenu(List<Menu> menus, OrderLineItemRequest orderLineItem) {
return menus.stream().filter(menu -> menu.getId().equals(orderLineItem.getMenuId()))
.findFirst().orElseThrow((NoSuchElementException::new));
}

Choose a reason for hiding this comment

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

Dto ์—์„œ ๋‹ค๋ฅธ ์˜์—ญ์˜ ๋„๋ฉ”์ธ์„ ์˜์กดํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ ๊ฐ™๋„ค์š”
Order ๋ผ๋Š” ์˜์—ญ์—์„œ Menu ์— ๋Œ€ํ•œ ๋„๋ฉ”์ธ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๋ฉด ์–ด๋–ค ๋‹จ์ ์ด ์žˆ์„๊นŒ์š”?

Copy link
Author

@hoa0217 hoa0217 Jul 2, 2024

Choose a reason for hiding this comment

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

์ผ๋‹จ DTO์—์„œ ์—”ํ‹ฐํ‹ฐ ์ƒ์„ฑ์— ๋Œ€ํ•œ ์ฑ…์ž„์€ ์ œ๊ฑฐํ•˜๋„๋กํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!
๊ทธ๋Ÿฌ๋‚˜ OrderLineItem์ด menuId์— ๋Œ€ํ•œ ์ฐธ์กฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๋ณด๋‹ˆ.. ์˜ฌ๋ฐ”๋ฅธ Menu์ธ์ง€ ์•„๋‹Œ์ง€ ๊ฒ€์ฆ์€ ํ•„์š”ํ• ๊ฑฐ๊ฐ™์€๋ฐ ํŒฉํ† ๋ฆฌ ํด๋ž˜์Šค๋ฅผ ๋„์ถœํ•˜์—ฌ ํ•ด๋‹น ์ž‘์—…์„ ์ง„ํ–‰ํ•˜๋Š”๊ฒŒ ์ข‹์œผ๋ ค๋‚˜์š”ใ… ใ… 

OrderLineItemMapperํด๋ž˜์Šค(์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋น„์Šค)๋ฅผ ๋„์ถœํ•ด์„œ ํ•ด๋‹น ์ž‘์—…์„ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค!

Comment on lines +30 to +36
@Column(name = "type", nullable = false, columnDefinition = "varchar(255)")
@Enumerated(EnumType.STRING)
private OrderType type;

@Column(name = "status", nullable = false, columnDefinition = "varchar(255)")
@Enumerated(EnumType.STRING)
private OrderStatus status;

Choose a reason for hiding this comment

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

๋ชจ๋ธ๋ง์„ ๋ณด์•˜์„ ๋•Œ๋„ ์ฃผ๋ฌธ ์œ ํ˜•์— ๋”ฐ๋ผ ํ•„์š”ํ•œ ์ฃผ๋ฌธ ์ƒํƒœ ๊ฐ’์ด ๋‹ค๋ฅด๋‹ค๋Š” ๊ฑธ ์ธ์ง€ํ•˜์…จ๋Š”๋ฐ์š”~
๊ทธ๋Ÿผ OrderType ๊ณผ OrderStatus ๋Š” ๊ณตํ†ต์œผ๋กœ ๋ณผ ์ˆ˜ ์žˆ์„๊นŒ์š”?

Copy link
Author

@hoa0217 hoa0217 Jul 2, 2024

Choose a reason for hiding this comment

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

๋‘๊ฐœ๋ฅผ ๋ถ„๋ฆฌํ• ๊นŒ ๊ณ ๋ฏผ์„ ํ–ˆ์ง€๋งŒ, Order๋ผ๋Š” ์ถ”์ƒํด๋ž˜์Šค์—์„œ ๊ณตํ†ต์œผ๋กœ ์“ฐ์ด๋Š” ์†์„ฑ์ด ๋งž๋‹ค๊ณ  ํŒ๋‹จ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค.

  • OrderType: OrderType์˜ ๊ฒฝ์šฐ Order๋ฅผ ์ƒ์†ํ•˜๋Š” ํด๋ž˜์Šค ํƒ€์ž…์„ ๊ตฌ๋ถ„ํ•˜๋Š” ์ปฌ๋Ÿผ์œผ๋กœ ์‚ฌ์šฉ๋˜๊ณ ์žˆ์–ด ์ œ๊ฐ€ ์ƒ์†์„ ์„ ํƒํ•œ ์ด์ƒ common์— ์žˆ์„ ํ•„์š”๊ฐ€ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.
  • OrderStatus: ์ฃผ๋ฌธ ์ข…๋ฅ˜๋ณ„๋กœ ๋‹ค๋ฅธ EnumType์„ ์“ฐ๊ฒŒ๋˜๋ฉด ์ƒ์† ์‹œ ์‹ฑ๊ธ€ํ…Œ์ด๋ธ”์ „๋žต์„ ๋ชป์“ฐ๊ณ  ํ…Œ์ด๋ธ”์„ ๋ถ„๋ฆฌํ•ด์•ผํ•˜๋”๋ผ๊ตฌ์š”.. ๋˜ํ•œ ์ค‘๋ณต๋˜๋Š” ์ƒํƒœ๋“ค์ด ๋‹ค์ˆ˜๋กœ ์กด์žฌํ•˜๋Š”๋ฐ ์ด๋ฅผ ๋”ฐ๋กœ ํด๋ž˜์Šค๋กœ ๋นผ๋Š”๊ฒŒ ๋งž๋Š”๊ฑธ๊นŒ?๋ผ๋Š” ๊ณ ๋ฏผ์ด ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

import kitchenpos.orders.common.domain.tobe.OrderLineItem;

@Entity
public class StoreOrder extends Order {

Choose a reason for hiding this comment

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

์ถ”์ƒ ํด๋ž˜์Šค์˜ ํ™œ์šฉ ๐Ÿ‘
๋‹ค๋ฅธ ์ฃผ๋ฌธ ํƒ€์ž…๋“ค๋„ ์ถ”๊ฐ€ํ•ด๋ณด๋ฉด ์–ด๋–จ๊นŒ์š”?

Copy link
Author

Choose a reason for hiding this comment

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

๋„ต ์ถ”๊ฐ€ ํ›„ ๋ฆฌ๋ทฐ ์š”์ฒญํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!! ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค

hoa0217 added 9 commits July 2, 2024 15:19
โ€ฆValidator ํด๋ž˜์Šค๋ช… ๋ณ€๊ฒฝ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants