Skip to content

๐Ÿš€ 1๋‹จ๊ณ„ - ๋ฆฌํŒฉํ„ฐ๋ง(์ƒํ’ˆ)#241

Open
shinseongsu wants to merge 8 commits into
next-step:shinseongsufrom
shinseongsu:step1
Open

๐Ÿš€ 1๋‹จ๊ณ„ - ๋ฆฌํŒฉํ„ฐ๋ง(์ƒํ’ˆ)#241
shinseongsu wants to merge 8 commits into
next-step:shinseongsufrom
shinseongsu:step1

Conversation

@shinseongsu
Copy link
Copy Markdown

๋Šฆ๊ฒŒ ์ œ์ถœํ•ด์„œ ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค

์š”๊ตฌ์‚ฌํ•ญ๋Œ€๋กœ, tobe ํŒจํ‚ค์ง€๋ฅผ ๋งŒ๋“ค์–ด ์ถ”๊ฐ€๋˜๋Š” domain์€ ๊ทธ๊ณณ์— ์ถ”๊ฐ€ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

Copy link
Copy Markdown

@kyucumber kyucumber left a comment

Choose a reason for hiding this comment

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

์•ˆ๋…•ํ•˜์„ธ์š”

๋ช‡๊ฐ€์ง€ ์ฝ”๋ฉ˜ํŠธ ๋‚จ๊ฒจ๋‘์—ˆ์œผ๋‹ˆ ํ™•์ธ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

this.purgomalumClient = purgomalumClient;
}

@Transactional
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

์ค‘์š”ํ•œ ๋ถ€๋ถ„์€ ์•„๋‹ˆ๋‚˜, ๋น ํŠธ๋ฆฌ์ง€ ์•Š๋„๋ก ํด๋ž˜์Šค ๋ ˆ๋ฒจ๋กœ ์–ด๋…ธํ…Œ์ด์…˜์„ ๋‹ฌ์•„๋„ ๊ดœ์ฐฎ์„ ๊ฒƒ ๊ฐ™๋„ค์š”.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

๊ทธ๋ ‡๊ตฐ์š” @transactional ์ด ์ค‘๋ณต์œผ๋กœ ๋ฉ”์†Œ๋“œ์— ๋ถ™์–ด ์žˆ๋„ค์š”

@Service
public class ProductService {
private final ProductRepository productRepository;
private final ProductMenuService productMenuService;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด Menu ์ปจํ…์ŠคํŠธ์™€ ๊ฒฐํ•ฉ์„ ๋‚ฎ์ถฐ์ฃผ์‹  ๋ถ€๋ถ„์ด ์ข‹๋„ค์š” ๐Ÿ‘

}

@Override
public void validMenuDisplay(final UUID productId) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๋ฉ”์„œ๋“œ ์ด๋ฆ„์€ valid์ด์ง€๋งŒ ์‹ค์ œ๋กœ validate์˜ ๋ชฉ์ ์ด ์•„๋‹ˆ๋ผ ๊ฐ€๊ฒฉ์„ ํ™•์ธํ•˜๊ณ  ์กฐ๊ฑด์— ๋งž์ง€ ์•Š์œผ๋ฉด menu์˜ ๋…ธ์ถœ ์—ฌ๋ถ€(displayed)๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฉ”์„œ๋“œ ์ด๋ฆ„์„ ๋ณ€๊ฒฝํ•˜๋Š”๊ฒŒ ์–ด๋–จ๊นŒ์š”?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

changeMenuDisplay ๊ฐ™์€ ์ด๋ฆ„์œผ๋กœ ์ˆ˜์ •ํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

}

@Override
public void validMenuDisplay(final UUID productId) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ๊ฒฐํ•ฉ๋„๋ฅผ ๋‚˜๋ˆ„์–ด ์ฃผ์‹  ๋ถ€๋ถ„์€ ์ข‹์œผ๋‚˜ ์ง€๊ธˆ์˜ ๊ตฌํ˜„์ด๋ผ๋ฉด Spring์˜ ApplicationEvent๋ฅผ ์‚ฌ์šฉํ•ด๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“œ๋„ค์š”.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

๋งˆ์ง€๋ง‰ ๊ฐ•์˜๋•Œ @eventlistener ๊ฐ•์˜ ํ•ด์ฃผ์—ˆ๋Š”๋ฐ ์จ๋ณด๋ฉด ์ข‹๊ฒ ๊ตฐ์š” ใ…Žใ…Ž

Comment on lines +15 to +19
@Embedded
private ProductName name;

@Embedded
private ProductPrice price;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ValueObject ์‚ฌ์šฉ ๐Ÿ‘

Comment on lines +53 to +54
final Product product = productRepository.findById(productId)
.orElseThrow(NoSuchElementException::new);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

์ด๋ฒˆ ๋ฏธ์…˜์€ ๋„๋ฉ”์ธ ์ชฝ๋งŒ ๋ฆฌํŒฉํ„ฐ๋งํ•˜๋Š”๊ฑฐ๊ธด ํ•˜์ง€๋งŒ ์ฐธ๊ณ ๋กœ ์ฝ”๋ฉ˜ํŠธ ๋‚จ๊น๋‹ˆ๋‹ค.

NoSuchElementException์ด ๋ฐœ์ƒํ•˜๋ฉด ์–ด๋–ค ์—๋Ÿฌ ์‘๋‹ต์ด ๋‚˜๊ฐ€๊ฒŒ ๋ ๊นŒ์š”? ์ด์™€ ๊ด€๋ จํ•ด์„œ RestControllerAdvice ๋“ฑ์œผ๋กœ ์ฒ˜๋ฆฌํ•ด์ค„ ํ•„์š”๋Š” ์—†์„๊นŒ์š”?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

GlobalRestController ์“ฐ๋ฉด ๋” ์ •ํ™•ํžˆ ์‘๋‹ต๊ฐ’์„ ๋ฐ›์•„ ๋ณผ ์ˆ˜ ์žˆ๊ฒ ๊ตฐ์š” ใ…Žใ…Ž

import java.math.BigDecimal;
import java.util.UUID;

public class ProductInfo {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

์ง€๊ธˆ ์•„๋ž˜์™€ ๊ฐ™์ด ๊ตฌ์„ฑํ•ด์ฃผ์‹  ๊ฒƒ ๊ฐ™๋„ค์š”

  • Product ๊ด€๋ จ Request, Response
  • ProductInto
  • Product(Entity)

์ด๋ ‡๊ฒŒ ๋˜๋ฉด ProductInfo๋ผ๋Š” ๋„๋ฉ”์ธ ํด๋ž˜์Šค์— ๋„๋ฉ”์ธ ๋กœ์ง(Value Object ๋“ฑ)์ด ์ ์šฉ๋˜์–ด์•ผ ํ•˜์ง€ ์•Š์„๊นŒ์š”? ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ ˆ์ด์–ด์™€ ๊ฒฐํ•ฉ๋˜๊ณ  ์žˆ๋Š” Entity๊ฐ€ ๋„๋ฉ”์ธ ๋กœ์ง์„ ๊ฐ€์ง€๋Š” ๊ฒƒ ๋ณด๋‹จ ๋„๋ฉ”์ธ ํด๋ž˜์Šค๊ฐ€ ๋„๋ฉ”์ธ ๋กœ์ง์„ ๊ฐ€์ง€๋Š”๊ฒŒ ์ ์ ˆํ•ด๋ณด์—ฌ์š”.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

DM์œผ๋กœ๋„ ๋“œ๋ ธ์ง€๋งŒ, Productinfo๊ฐ€ DTO ์—ญํ™œ์„ ํ•˜๊ณ  ์‹ถ์–ด์„œ ๋งŒ๋“ ๊ฒƒ์ด๋ผ์„œ, @kyucumber ๋ฆฌ๋ทฐ์–ด๋‹˜ ๋ง์”€๋Œ€๋กœ entity ๋ณด๋‹ค๋Š” vo๋ฅผ ๋งŒ๋“ค์–ด ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์ด DB์— ์˜ํ–ฅ์— ๋œ ๊ฐˆ๊ฒƒ๊ฐ™์Šต๋‹ˆ๋‹ค ใ…Žใ…Ž

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