Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.example.kong;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/* Spring Boot에서 컨트롤러는 어떻게 인식할까요? */
@RequiredArgsConstructor
@RestController
public class KongController {

private KongService kongService;
private final KongService kongService;

@GetMapping("/reaction")
public String reaction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@
import com.example.kong.util.DrinkPrinter;
import com.example.kong.util.DrinkProperties;
import com.example.kong.util.Space;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/* Spring Boot에서 서비스는 어떻게 인식할까요? */
@Service
@RequiredArgsConstructor
public class KongService {

/* 어떻게 주입받아야 할까요? */
private DrinkProperties drinkProperties;
private final DrinkProperties drinkProperties;

// 냄새가 나는 코드지만 예제를 위한 부분이니 신경쓰지 말아주세요..
public String reactToDrink() {
Space wouldYou = new Space();
String drink = drinkProperties.getDrink();

if (drink.equals("coffee"))
if (drink.equals("coffee")) {
DrinkPrinter.printCoffee();
else if (drink.equals("coke"))
} else if (drink.equals("coke")) {
DrinkPrinter.printCoke();
else
} else {
throw new RuntimeException("무슨 음료인지 모르겠어요..");
}
return wouldYou.reactTo(drink);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
spring:
kong:
what-kind-of-drink: 'coffee'
what-kind-of-drink: 'coke'