-
Notifications
You must be signed in to change notification settings - Fork 0
[크리스마스 프로모션] 전호건 리뷰부탁드립니다. #1
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
base: review
Are you sure you want to change the base?
Changes from all commits
6ce312b
2ab22a7
5148d1c
dd073f1
e2c41f0
0343767
7446c16
2557ff1
fe502fa
6cc70b8
f7bf2f5
eaf977a
6941daa
3f34870
679a011
c7c3bcd
724850d
0e5a39d
e1dd93d
4ad1a77
7ace7f7
331faa7
9369b1a
03ae550
b6aa4b4
46e266c
a6bed6f
7363139
9f563ca
bdff0dc
0b0fb5a
cac8050
d79d7ae
4a6a5f7
c72e102
14608c5
af80262
4afb646
915ed8e
1db33fe
ad531b6
96fc0a2
65ee275
1140134
1ab2942
dcc86e4
febfab4
1d80e5f
59de3c9
6065e6d
ee52cb3
fcc1128
980cf07
52eb133
aa077d6
0f2f8e2
e8955eb
13c8517
98eb8b7
e98b479
8a091b4
f605a01
f52a7ef
0f27050
d465eaa
6e9092c
f2934bb
d1ccd47
33f2f4c
e4d740d
e967d9a
ad80102
e342118
20d301e
20c90eb
2efbb8f
c9482cd
8c167e6
368e026
af51be2
879bfa7
71c3020
faf0395
0e52ac3
7c1d6d2
fbe81d8
b9767b5
bb86fd9
86581e3
80d54eb
8dfe9a1
9fa529c
6db13d9
5f55b68
76af671
6ddc0dc
31b02b6
0372329
087fcad
0f7b30f
8088fca
ad5e487
57b399d
8e47abf
7328697
3c23590
0a1c72b
c100ff5
8045f2b
c39e581
4e7722e
743c70a
58ac48a
83592b5
85b623b
c3947d6
0d3c7c9
30cffdf
f98c8f3
64ab5fa
d11dd5a
57cc59b
d5402f0
efe711c
de27654
ec12d45
af4a309
6f71e6b
b5b28df
4f7e4d1
fdff529
71cd483
0742c29
76767ed
489b2f3
537fdf3
0fabdda
cab77e2
f172fed
ad17865
ffbe20f
5c4a7bb
9f23ea2
f55ebb5
90f640f
8e4ea09
edc51b9
930c064
7bd2adf
8255fac
5a93576
e93de6e
e2904b7
bf4100e
55d15cd
ff7936d
a76f1be
cec2816
e5ea3f4
48e68f5
2e7aabb
307c23a
47436ea
638d9d6
4b589e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,279 @@ | ||
| ### 🖥️ 프로그램 소개 | ||
| 주문을 받아서 이벤트 적용 내역을 출력하는 프로그램입니다. | ||
|
|
||
| ### 💡 핵심 기능 | ||
| 적용 가능한 이벤트 혜택 내역 계산 | ||
|
|
||
| ### 📌 주요 포인트 | ||
| - 할인 이벤트와 선물 이벤트를 <b>인터페이스</b>와 <b>추상 클래스</b>로 분리와 동시에 공통 로직 통합 | ||
| - 여러 종류의 이벤트를 <b>Enum</b>과 <b>함수형 인터페이스</b>로 관리 | ||
| - MVC 패턴에 <b>Service</b>, <b>Repository</b>를 추가하여 역할 분리 | ||
| - <b>Enum</b>과 <b>EnumMap</b>으로 불필요 클래스 제거 및 통합 관리 | ||
| - <b>계층형 Dto</b>를 활용한 View와 Domain 의존성 분리 | ||
|
|
||
| ### 📉 런타임 의존관계도 | ||
|  | ||
|
|
||
| ### 📊 UML | ||
|  | ||
|
|
||
| ### ⚒️ 클래스 역할 | ||
| <div align="center"> | ||
| <table> | ||
| <tr> | ||
| <th align="center">📁 Package</th> | ||
| <th align="center">📚 Class</th> | ||
| <th align="center">✏️ Description</th> | ||
| </tr> | ||
| <tr> | ||
| <td rowspan="1">🗓️ <b>config</b></td> | ||
| <td><b>PlannerConfig</b></td> | ||
| <td>의존관계 설정</td> | ||
| </tr> | ||
| <tr><td colspan="3"></td></tr> | ||
| <tr> | ||
| <td rowspan="2">⚙️ <b>controller</b></td> | ||
| <td><b>OrderController</b></td> | ||
| <td>주문 입출력(View), 주문(Service) 연결</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>OrderConverter</b></td> | ||
| <td>View 입력값 Order 인스턴스 변수로 변환</td> | ||
| </tr> | ||
| <tr><td colspan="3"></td></tr> | ||
| <tr> | ||
| <td rowspan="2">📐 <b>domain</b><br>⇛ order</td> | ||
| <td><b>Order</b></td> | ||
| <td>주문 일자와 메뉴 수량을 갖는 클래스</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>Day</b></td> | ||
| <td>12월의 일자 원시타입 포장 클래스</td> | ||
| </tr> | ||
| <tr> | ||
| <td rowspan="5"><b>domain</b><br>⇛ order<br>⇛ constant</td> | ||
| <td><b>Category</b></td> | ||
| <td>메뉴의 카테고리 Enum</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>DayOfWeek</b></td> | ||
| <td>요일 Enum</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>December</b></td> | ||
| <td>12월 Enum</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>Menu</b></td> | ||
| <td>메뉴 Enum</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>Week</b></td> | ||
| <td>평일/주말 Enum</td> | ||
| </tr> | ||
| <tr> | ||
| <td rowspan="3"><b>domain</b><br>⇛ event</td> | ||
| <td>📗 <b>Event</b></td> | ||
| <td>이벤트 혜택 계산 인터페이스</td> | ||
| </tr> | ||
| <tr> | ||
| <td>📗 <b>EventRepository</b></td> | ||
| <td>이벤트 혜택 결과 저장 추상 클래스</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>Badge</b></td> | ||
| <td>배지 Enum</td> | ||
| </tr> | ||
| <tr> | ||
| <td rowspan="2"><b>domain</b><br>⇛ event<br>⇛ discount</td> | ||
| <td>🎁 <b>DiscountEventType</b></td> | ||
| <td>Event 인터페이스 구현, 할인 이벤트 통합 관리 Enum</td> | ||
| </tr> | ||
| <tr> | ||
| <td>💾 <b>DiscountRepository</b></td> | ||
| <td>EventRepository 구현, 할인 이벤트 결과 EnumMap 저장</td> | ||
| </tr> | ||
| <tr> | ||
| <td rowspan="2"><b>domain</b><br>⇛ event<br>⇛ gift</td> | ||
| <td>🎁 <b>GiftEventType</b></td> | ||
| <td>Event 인터페이스 구현, 선물 이벤트 통합 관리 Enum</td> | ||
| </tr> | ||
| <tr> | ||
| <td>💾 <b>GiftRepository</b></td> | ||
| <td>EventRepository 구현, 선물 이벤트 결과 EnumMap 저장</td> | ||
| </tr> | ||
| <tr><td colspan="3"></td></tr> | ||
| <tr> | ||
| <td rowspan="1">🕹️ <b>service</b><br>⇛ order</td> | ||
| <td><b>OrderService</b></td> | ||
| <td>주문 생성 및 주문 결과 요약</td> | ||
| </tr> | ||
| <tr> | ||
| <td rowspan="4"><b>service</b><br>⇛ event</td> | ||
| <td><b>EventDetailService</b></td> | ||
| <td>이벤트 적용 상세 결과 요약</td> | ||
| </tr> | ||
| <tr> | ||
| <td>📗 <b>EventService</b></td> | ||
| <td>이벤트 혜택 결과 계산 추상 클래스</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>DiscountService</b></td> | ||
| <td>EventService 구현, 할인 해택 적용</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>GiftService</b></td> | ||
| <td>EventService 구현, 선물 해택 적용</td> | ||
| </tr> | ||
| <tr><td colspan="3"></td></tr> | ||
| <tr> | ||
| <td rowspan="2">⏰ <b>exception</b></td> | ||
| <td><b>OrderException</b></td> | ||
| <td>주문 생성 예외 발생</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>ErrorMessage</b></td> | ||
| <td>예외 메시지 Enum</td> | ||
| </tr> | ||
| <tr><td colspan="3"></td></tr> | ||
| <tr> | ||
| <td rowspan="6">📬 <b>response</b></td> | ||
| <td><b>OrderSummaryResponse</b></td> | ||
| <td>주문 결과 요약 DTO</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>OrderResponse</b></td> | ||
| <td>주문 항목 DTO</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>MenuCountResponse</b></td> | ||
| <td>주문 메뉴 수량 DTO</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>EventDetailResponse</b></td> | ||
| <td>이벤트 적용 상세 내역 DTO</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>EventResponse</b></td> | ||
| <td>이벤트 적용 내역 DTO</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>GiftMenuResponse</b></td> | ||
| <td>선물 메뉴 수량 DTO</td> | ||
| </tr> | ||
| <tr><td colspan="3"></td></tr> | ||
| <tr> | ||
| <td rowspan="4">🖥️ <b>view</b></td> | ||
| <td><b>InputView</b></td> | ||
| <td>입력 요청 View</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>OutputView</b></td> | ||
| <td>결과 출력 View</td> | ||
| </tr> | ||
| <tr> | ||
| <td>📗 <b>Reader</b></td> | ||
| <td>입력 인터페이스</td> | ||
| </tr> | ||
| <tr> | ||
| <td>📗 <b>Writer</b></td> | ||
| <td>출력 인터페이스</td> | ||
| </tr> | ||
| <tr> | ||
| <td rowspan="2"><b>view</b><br>⇛ io</td> | ||
| <td><b>ConsoleReader</b></td> | ||
| <td>콘솔 입력</td> | ||
| </tr> | ||
| <tr> | ||
| <td><b>ConsoleWriter</b></td> | ||
| <td>콘솔 출력</td> | ||
| </tr> | ||
|
|
||
|
|
||
| </table> | ||
| </div> | ||
|
|
||
| <br> | ||
|
|
||
| ### 🗂️ 구현 기능 목록 | ||
| #### ⚙️ Controller | ||
| - #### OrderController | ||
| - [x] 입력 오류시 반복 요청 | ||
| - #### OrderConverter | ||
| - [x] 입력 날짜 숫자 검증 | ||
| - [x] 입력 날짜 숫자 변환 | ||
| - [x] 중복 메뉴 검증 | ||
| - [x] 개수 숫자 검증 | ||
| - [x] 개수 숫자 변환 | ||
| - [x] 메뉴 개수 포맷 검증 | ||
| #### 📐 Domail | ||
| - #### Day | ||
| - [x] 입력 날짜 범위 검증 (1 ~ 31) | ||
| - [x] 날짜 차이 계산 | ||
| - [x] 날짜 대소비교 기능 | ||
| - #### Order | ||
| - [x] 메뉴 개수 범위 검증 (1이상) | ||
| - [x] 총 주문 메뉴 개수 검증 (20이하) | ||
| - [x] 음료만 주문 검증 | ||
| - [x] 카테고리별 수량 계산 | ||
| - [x] 할인 전 총주문 금액 계산 | ||
| - #### Menu | ||
| - [x] 메뉴 유무 검증 | ||
| - #### Week | ||
| - [x] 평일/주말 구분 | ||
| - [x] 평일/주말 할인 카테고리 선택 | ||
| - #### DayOfWeek | ||
| - [x] 요일 구분 | ||
| - #### December | ||
| - [x] 크리스마스 확인 | ||
| - [x] 12월 날짜 확인 | ||
| - #### DiscountEventType | ||
| - [x] 전체 할인 적용 가능 판별 | ||
| - [x] 전체 할인 이벤트 적용하기 | ||
| - [x] 총주문 금액 10,000 이상 확인 | ||
| - [x] 크리스마스 디데이 할인 적용 여부 확인 | ||
| - [x] 크리스마스 디데이 할인 금액 계산 | ||
| - [x] 평일/주말 할인 적용 여부 확인 | ||
| - [x] 평일 할인 적용 금액 계산 | ||
| - [x] 주말 할인 적용 금액 계산 | ||
| - [x] 특별 할인 적용 금액 계산 | ||
| - [x] 특별 할인 적용 여부 확인 | ||
| - #### GiftEventType | ||
| - [x] 전체 선물 이벤트 적용 가능 판별 | ||
| - [x] 전체 선물 이벤트 적용하기 | ||
| - [x] 증정 이벤트 적용 여부 확인 | ||
| - [x] 증정 이벤트 적용 금액 계산 | ||
| - #### DiscountRepository | ||
| - [x] 할인 이벤트 결과 저장 | ||
| - [x] 할인 이벤트 전체 이익 계산 | ||
| - #### GiftRepository | ||
| - [x] 선물 이벤트 결과 저장 | ||
| - [x] 선물 이벤트 전체 이익 계산 | ||
| - [x] 선물 메뉴 항목, 수량 계산 | ||
| - #### Badge | ||
| - [x] 12월 이벤트 배지 등급 계산 | ||
| #### 🕹️ Service | ||
| - #### OrderService | ||
| - [x] 주문 내역, 이벤트 적용 내역 요약하기 | ||
| - #### EventDetailService | ||
| - [x] 이벤트 적용 내역 계신 | ||
| - [x] 총혜택 금액 계산 | ||
| - [x] 할인 후 예상 결제 금액 계산 | ||
| - #### DiscountService | ||
| - [x] 전체 할인 이벤트 적용하기 | ||
| - #### GiftService | ||
| - [x] 전체 선물 이벤트 적용하기 | ||
| #### 🖥️ View | ||
| - #### InputView | ||
| - [x] 방문 날짜 입력 받기 | ||
| - [x] 메뉴와 개수 입력 받기 | ||
| - #### OutputView | ||
| - [x] Hello 헤더 출력 | ||
| - [x] 증정 메뉴 출력 | ||
| - [x] 이벤트 혜택 미리보기 출력 | ||
| - [x] 주문 메뉴 출력 | ||
| - [x] 할인 전 총주문 금액 출력 | ||
| - [x] 혜택 내역 출력 | ||
| - [x] 총혜택 금액 출력 | ||
| - [x] 할인 후 예상 결제 금액 출력 | ||
| - [x] 12월 이벤트 배지 출력 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| package christmas; | ||
|
|
||
| import static christmas.config.PlannerConfig.orderController; | ||
|
|
||
| public class Application { | ||
|
|
||
| public static void main(String[] args) { | ||
| // TODO: 프로그램 구현 | ||
| orderController().run(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package christmas.config; | ||
|
|
||
| import christmas.controller.OrderController; | ||
| import christmas.domain.event.discount.DiscountRepository; | ||
| import christmas.domain.event.gift.GiftRepository; | ||
| import christmas.service.event.DiscountService; | ||
| import christmas.service.event.EventDetailService; | ||
| import christmas.service.event.GiftService; | ||
| import christmas.service.order.OrderService; | ||
| import christmas.view.InputView; | ||
| import christmas.view.OutputView; | ||
| import christmas.view.io.ConsoleReader; | ||
| import christmas.view.io.ConsoleWriter; | ||
|
|
||
| public class PlannerConfig { | ||
|
|
||
| private PlannerConfig() { | ||
| } | ||
|
|
||
| public static OrderController orderController() { | ||
| return new OrderController(inputView(), outputView(), orderService()); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 우왓.. Config 파일에서 이런 식으로 객체를 생성하는 방법을 생각지도 못했는데, static 메서드를 사용하니 깔끔하네요..! 👍 |
||
|
|
||
| private static InputView inputView() { | ||
| return new InputView(new ConsoleReader(), new ConsoleWriter()); | ||
| } | ||
|
|
||
| private static OutputView outputView() { | ||
| return new OutputView(new ConsoleWriter()); | ||
| } | ||
|
|
||
| private static OrderService orderService() { | ||
| return new OrderService(eventDetailService()); | ||
| } | ||
|
|
||
| private static EventDetailService eventDetailService() { | ||
| return new EventDetailService(discountService(), giftService()); | ||
| } | ||
|
|
||
| private static DiscountService discountService() { | ||
| return new DiscountService(new DiscountRepository()); | ||
| } | ||
|
|
||
| private static GiftService giftService() { | ||
| return new GiftService(new GiftRepository()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package christmas.controller; | ||
|
|
||
| import christmas.controller.converter.OrderConverter; | ||
| import christmas.domain.order.Day; | ||
| import christmas.domain.order.Order; | ||
| import christmas.response.OrderSummaryResponse; | ||
| import christmas.service.order.OrderService; | ||
| import christmas.view.InputView; | ||
| import christmas.view.OutputView; | ||
| import java.util.function.Supplier; | ||
|
|
||
| public class OrderController { | ||
|
|
||
| private final InputView inputView; | ||
| private final OutputView outputView; | ||
| private final OrderService orderService; | ||
|
|
||
| public OrderController(final InputView inputView, final OutputView outputView, final OrderService orderService) { | ||
| this.inputView = inputView; | ||
| this.outputView = outputView; | ||
| this.orderService = orderService; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. final을 꼼꼼히 달아주셨네요 👍 이를 통해 예기치 않은 변화로 발생하는 문제를 방지할 수 있겠네요 :) |
||
|
|
||
| public void run() { | ||
| outputView.printHello(); | ||
|
|
||
| final Day orderDay = createOrderDay(); | ||
| final Order order = createOrder(orderDay); | ||
|
|
||
| final OrderSummaryResponse orderSummaryResponse = orderService.createOrderSummary(order); | ||
|
|
||
| outputView.printOrderSummary(orderSummaryResponse); | ||
|
|
||
| inputView.close(); | ||
| } | ||
|
|
||
| private Day createOrderDay() { | ||
| return getByRoof(() -> OrderConverter.convertToDay(inputView.readDate())); | ||
| } | ||
|
|
||
| private Order createOrder(final Day day) { | ||
| return getByRoof(() -> Order.of(day, OrderConverter.convertToMenu(inputView.readMenuAndCount()))); | ||
| } | ||
|
|
||
| private <T> T getByRoof(final Supplier<T> method) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요렇게 함수형 인터페이스 적용하는 것 깔끔합니다!! 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분은 재사용성을 고려하여 따로 Util로 빼는 것은 어떨까요?
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 빼는 것도 좋아보입니다. |
||
| while (true) { | ||
| try { | ||
| return method.get(); | ||
| } catch (IllegalArgumentException illegalArgumentException) { | ||
| outputView.printError(illegalArgumentException.getMessage()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확장성을 고려해서 Config파일로 orderController를 생성하셨군요 이런 방법이 있는 줄 몰랐네요
좋은 지식 배우고갑니다! 👍