-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathConsoleApplication.java
More file actions
43 lines (38 loc) · 1.45 KB
/
ConsoleApplication.java
File metadata and controls
43 lines (38 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.prgrms.springbootbasic;
import com.prgrms.springbootbasic.enums.ConsoleMenu;
import com.prgrms.springbootbasic.view.Console;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
@Profile("!test")
@Slf4j
@Component
@RequiredArgsConstructor
public class ConsoleApplication implements CommandLineRunner {
private final ConsoleVoucher consoleVoucher;
private final ConsoleCustomer consoleCustomer;
private final Console console;
@Override
public void run(String... args) throws Exception {
while (true) {
console.printConsoleMenu();
try {
ConsoleMenu inputMenu = ConsoleMenu.of(console.inputCommand());
switch (inputMenu) {
case CUSTOMER -> consoleCustomer.menu();
case VOUCHER -> consoleVoucher.menu();
case EXIT -> {
console.printExitMessage();
return;
}
}
} catch (IllegalArgumentException e) {
log.error("명령어가 잘못 입력되었습니다.", e.getMessage());
} catch (Exception e) {
log.error("프로그램에서 오류가 발생하였습니다.", e.getMessage());
}
}
}
}