-
Notifications
You must be signed in to change notification settings - Fork 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
๐ณ ๊ฒฐ์ ์๋น์ค #10
base: develop
Are you sure you want to change the base?
Conversation
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.
์๊ณ ๋ง์ผ์ จ์ต๋๋ค. ์ข ๋ ์ ์ฐํ ์ฝ๋๋ฅผ ์ด๋ป๊ฒ ์์ฑํ ์ ์์๊น๋ฅผ ์๊ฐํ๋ฉด์ ๋ฆฌ๋ทฐ๋ฅผ ๋๋ ค๋ดค์ด์ ใ ใ ์ ๊ฐ ๋ฌด์กฐ๊ฑด ์ณ์ ๊ฑด ์๋๋ ๋์ํ์๋ ๋ถ๋ถ๋ง ์์ ํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์์ :)
build.gradle
Outdated
@@ -47,7 +48,7 @@ dependencies { | |||
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2', 'io.jsonwebtoken:jjwt-jackson:0.11.2' | |||
compileOnly 'org.projectlombok:lombok' | |||
developmentOnly 'org.springframework.boot:spring-boot-devtools' | |||
implementation 'org.springframework.boot:spring-boot-starter-log4j2:2.6.0' | |||
implementation 'org.springframework.boot:spring-boot-starter-log4j2:2.6.2' |
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.
logback๋ ์๋๋ฐ log4j2๋ฅผ ์ฌ์ฉ ํ์ ์ด์ ๊ฐ ์์ผ์ค๊น์?? ์ต๊ทผ log4j2 ๋ณด์ ์ทจ์ฝ์ ์ด ์์ด์ ํด๋น ๋ด์ฉ๋ ํ๋ฒ ์ดํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์์ :)
ref:
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.
์ ๊ทธ ๋ถ๋ถ์ ์ ๊ฐ ์ฌ์ค ํฌ๊ฒ ๊ณ ๋ฏผํ๊ณ ์ด๊ฑด ์๋๋ผ์ ์ด๋ฒ์ ๊ณ ๋ฏผํด๋ณผ๊ฒ์ ์ฝ๋ฉํธ ๊ฐ์จํฉ๋๋ค ๐
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.
๊ทผ๋ฐ ์ด๊ฑฐ ์ ๋ ๋ฒ์ ์ ๊ทธ๋ ์ด๋ ์์ผ์ค์ ๋ณด์ ์ทจ์ฝ์ ๋์ํ๋ค๊ณ ํ๋๋ฐ ๊ทธ๋ผ์๋ ์ทจ์ฝํ๋ค๊ณ Maven Repository์๋ ๋จ๋ค์... ๐ ์์ ๋ฐ๊ฟ์ผ๊ฒ ์ด์ ์ด์ฐธ์
|
||
@Getter | ||
@Setter | ||
@RequiredArgsConstructor |
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.
final์ธ ํ๋๊ฐ ์์ด์ ์ํ์๋๋๋ก ์ฝ๋๊ฐ generate๋์ง ์๊ณ ๊ธฐ๋ณธ์์ฑ์๋ก ์์ฑ๋ ๊ฒ ๊ฐ์์. dto๋ ๋ณดํต ๋ถ๋ณ๊ฐ์ฒด๋ก ์ฌ์ฉํ๊ธฐ์ํด final ๋ณ์๋ฅผ ์ ์ธํ์ฌ ์ฌ์ฉํฉ๋๋ค. ํ์ง๋ง framework์์ setter๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ๋๋ฌธ์ ์ด์ฉ์ ์์ด setter๋ฅผ ์ ์ ํ๋ ๊ฒฝ์ฐ๊ฐ ์๋๋ฐ์. ํด๋น ๊ฒฝ์ฐ๋ง ์ ์ธํ๊ณ final ๋ณ์๋ก ์ ์ธํ์ฌ ๋ถ๋ณ๊ฐ์ฒด๋ก ์ด์ฉํ์๋๊ฒ ์ข์ต๋๋ค.
immutable object ref:
spring framework setter ref:
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.
์ ๋ต๋ต ํด๋น ๋ถ๋ถ ์ฐธ๊ณ ํด์ ๋ฆฌํฉํ ๋ง ์งํํ๊ฒ ์ต๋๋ค!
@@ -65,4 +68,12 @@ public void enterChatRoom(String roomId) { | |||
public ChannelTopic getTopic(String roomId) { | |||
return topics.get(roomId); | |||
} | |||
|
|||
public UserDto infoAuctionWinner(BigInteger id) { |
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.
method naming์ ์ผ๊ด์ฑ์ด ์์ผ๋ฉด ์ข์ ๊ฒ ๊ฐ์์. ์ด๋ค ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ฌ ๋๋ getXX์ด๊ณ ์ด๋ค ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ฌ๋๋ infoXX์ธ ๊ฒ ์ฒ๋ผ ๋ณด์ฌ์์. ์ฝ๋์ ์ผ๊ด์ฑ๋ ์ฝ๋ ๊ฐ๋ ์ฑ์ ์ค์ํ ๋ถ๋ถ์ด๋ผ์์ ใ ใ
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.
์ ๋ต๋ต ์ผ๊ด์ฑ ์๋ ๋ค์ด๋ฐ ๊ฐ์ ธ๊ฐ๋ณด๊ฒ ์ต๋๋ค...ใ
ใ
ใ
|
||
@Bean | ||
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) { | ||
return restTemplateBuilder.build(); |
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.
์ง๊ธ์ restTemplate ์์ฑ์ default๊ฐ์ผ๋ก ์ค์ ์ ์ด๊ธฐํ ํ์ง๋ง ์ค์ ์ด์์ ์ฌ์ฉ๋ ๋๋ ์ค์ ์ค์ ๊ฐ์ ์ ์ดํด๋ณด๊ณ ์ค์ ํด์ฃผ์ด์ผํฉ๋๋ค. ์๋ฅผ๋ค์ด connectionPoolSize, connectionTimeout, readTimeout ๊ฐ์ ๊ฐ๋ค์ด ๊ทธ ์ค ํ๋ ์ผ ๊ฒ ๊ฐ์์ :)
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.
์ ๋ต๋ต ์๊ฒ ์ต๋๋ค ์ผ๋จ ์ด ๋ถ๋ถ์ ์ ๊ฐ ์ด์๋ก ๋ฑ๋กํด๋๊ณ ์ด์์์ ๋๋ฆด ์ ์ ์์ ํ๋ ๋ฐฉํฅ์ผ๋ก ๊ฐ์ ธ๊ฐ๋ณผ๊ฒ์
public class PaymentController { | ||
|
||
private final PaymentService paymentService; | ||
@Value("${redirect.url}") |
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.
lombok config ํ์ผ์ ์ด์ฉํ๋ฉด final ๋ณ์๋ก ์ ์ธํ์๋ ์ฌ์ฉ์ด ๊ฐ๋ฅํฉ๋๋ค. lombok์ด ํด๋น ์ ๋ํ ์ด์ ์ ์์ฑ์์๋ ์ ์ฉํด์ฃผ๊ธฐ ๋๋ฌธ์ธ๋ฐ์. lombok.config ํ์ผ์ ํ๋ฒ ์ดํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์์.
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.
์ ๋ต๋ต ํด๋น ๋งํฌ ์ฐธ๊ณ ํด์ ๋ค๋ฅธ ๋ถ๋ถ๋ค๋ ์์ ํ๋ ๋ฐฉํฅ์ผ๋ก ๊ฐ๊ฒ ์ต๋๋ค!
@Value("${redirect.url}") | ||
private String serverUrl; | ||
|
||
@GetMapping("") |
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.
empty string์ ๊ผญ ์ค์ ํด์ฃผ์ด์ผํ๋์~?
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.
์ด๊ฑธ ์ ๋ฃ์ด์คฌ์๊น์...ใ ใ ใ ์ ๊ฐ ๋ดค์ ๋ ๊ฑ ๋ค๋ฅธ ํธ์ถ ๋ฉ์๋๋ ๋ค ์๋๋ฐ ์ ๊ฑฐ๋ง ์์ด์ ์์ฌ์ด(?) ๋ง์์ ์ถ๊ฐํ๋๊ฑฐ ๊ฐ์๋ฐ...๊ฑ ์ง์ฐ๋ ๋ฐฉํฅ์ผ๋ก ๊ฐ์ ธ๊ฐ๊ฒ ์ต๋๋ค;;
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.
@GetMapping("request") ์ด๋ ๊ฒ ๊ฐ์ ธ๊ฐ๊ฒ์!
return new ResponseEntity<>(payResult, httpHeaders, HttpStatus.OK); | ||
} | ||
|
||
@GetMapping("fail") |
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.
fail์์๋ ๋ณ๋์ ๋ก์ง ์ฒ๋ฆฌ๊ฐ ํ์์๋๊ฑธ๊น์?? ๊ฒฐ์ ์ํ๋ฅผ ์คํจ๋ก ๋ณ๊ฒฝํ๋ค๋์ง ๋ฑ์ ๋ก์ง์ด์ ์๋ฌด์ฒ๋ฆฌ๋ ์ํ๊ณ ์๋ต๋ง ๋ด๋ ค์ฃผ๋ api๊ฐ ํ์ํ๊ฑด๊ฐ ๊ถ๊ธํด์์ :)
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.
์ ์ ๊ฐ ๋ก์ง ์์ ํ๋ฉด์ ์ fail ์ฒ๋ฆฌ๋ฌ์ ์ ์ ํด์ค์ผ ํ๋ ์์ ์ด ์๋ก ์๊ธฐ๊ธด ํ์ต๋๋ค ํด๋น ๋ถ๋ถ ์์ ํด์ ๊ฐ์ ธ๊ฐ๋ณด๋๋ก ํ ๊ฒ์!
|
||
HttpEntity<String> request = new HttpEntity<>(objectMapper.writeValueAsString(payloadMap), headers); | ||
|
||
ResponseEntity<JsonNode> responseEntity = restTemplate.postForEntity( |
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.
์ ์ ๋ง์๋๋ ธ๋ฏ์ด ์ธ๋ถ ์ฐ๋์ ๋ณ๋์ adapter๋ ํด๋ผ์ด์ธํธ๋ฅผ ๋ง๋ค์ด์ ์ฒ๋ฆฌํ๋๊ฒ ์ข์ ๊ฒ ๊ฐ์์. ์ง์ ์ฒ๋ฆฌํ๋ค๋ณด๋ PaymentService๋ Toss ๊ฒฐ์ ๋ง์ ์ํ ๊ฐ์ฒด๊ฐ ๋์ด๋ฒ๋ ธ๋๋ฐ์. PaymentService ์๊ตฌ์กฐ๊ฑด์ ์นด์นด์คํ์ด ๊ฒฐ์ , ์นด๋ ๊ฒฐ์ ๋ฑ์ ๋ค์ํ ์๋จ์ด ์ถ๊ฐ๋๋ ์๊ตฌ ์ฌํญ์ด ์ถ๊ฐ๋๋ฉด ์ฝ๋๋ฅผ ๋ค ๋ฏ์ด๊ณ ์ณ์ผํ ๊ฒ ๊ฐ์์์. TossPaymentClient, KakaoPaymentClient ๊ฐ์ ํด๋์ค๋ฅผ ๋ง๋ค์ด์ ์ธ๋ถ์ฐ๋์ ํ๋ฉด ์ข์ ๊ฒ ๊ฐ์์. ๊ฒฐ์ ๋ผ๋ ๊ฐ๋ ์ ์ถ์ํํ์ฌ ์ฝ๋์ ๋ น์ฌ๋ด๋ฉด ๋ ์ข์ ์ฝ๋๊ฐ ๋ ๊ฒ ๊ฐ์์
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.
์ ๋ต๋ต ํด๋น ๋ถ๋ถ ์๊ทธ๋๋ ์์ ํ๋๋ฐ ์ฌ๊ธฐ ๋ถ๋ถ์๋ค ๊ฐ์ด ๋จธ์งํด์ ์ฌ๋ฆฌ๊ฒ ์ต๋๋ค~
|
||
JsonNode body = responseEntity.getBody(); | ||
|
||
TossPayDto payResult = TossPayDto.builder() |
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.
ํ๋์ ๋ฉ์๋๊ฐ ๋๋ฌด ๋ง์ ์ฑ ์์ ๊ฐ์ง๊ณ ์๋ ๊ฒ ๊ฐ์์.
- header setting
- payload๋ฅผ json serialize
- toss ๊ฒฐ์ ์ฐ๋
- response๋ฅผ dto๋ก parsing
ํด๋น ๋ฉ์๋๋ฅผ ํ ์คํธํ๋ ค๋ฉด ์์ ๋ด์ฉ๋ค์ด ๋ค ํ ์คํธํด์ผํ๋๋ฐ ํ ์คํธํ๊ธฐ๊ฐ ์ฌ์๋ณด์ด์ง ์์์์. 2๋ฒ์ JsonUtils ๊ฐ์ ๊ฐ์ฒด๋ฅผ ๋ง๋ค์ด์ json handling์ ์ฑ ์์ ์ฎ๊ฒจ์ค์ ์์ ๊ฒ ๊ฐ์์. json handling์ jackson์ ObjectMapper๊ฐ ์๋๋ผ Gson์ผ๋ก๋ ์ฒ๋ฆฌํ ์ ์๋๋ฐ json handling์ด ํ๋์ ๊ตฌํ์ฒด์ ๋๋ฌด ๊ฐ๊ฒฐํฉ ๋์ด์๋ ๊ฒ ๊ฐ์์. json๋ ๊ตฌํ์ฒด๊ฐ ์๋๋ผ ๋ฐ์ดํฐ ํฌ๋งท์ ๊ฐ๋ ์ ๋๋ค. ๊ตฌํ์ฒด๋ ์ฌ๋ฌ๊ฐ์ง๋ฅผ ์ฌ์ฉํ ์ ์์ด์ jackson์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ObjectMapper๋ฅผ ์ฌ์ฉํ๋ ๋ชจ๋ ์ฝ๋๋ฅผ ๋ค ๋ฐ๊ฟ์ค์ผํ๋๋ฐ ๊ฐ๋ฅํ ๊น์?? JsonUtils ์์ json์ handlingํด์ค๋ค๋ฉด JsonUtils๋ง ์ฝ๋๋ฅผ ์์ ํด ์ฃผ๋ฉด ๋์ด์ ์ฝ๋๊ฐ ์ข ๋ ์ ์ฐํด์ง ์ ์์ด์. ์ด์๊ฐ์ด Toss ์ฐ๋๋ PaymentClient๋ฅผ interface๋ก ๋ง๋ค์ด๋๊ณ ๊ฒฐ์ ๊ฐ๋ ์ ์ถ์ํํ๊ณ ๊ตฌํ์ฒด๋ ์ฌ๋ฌ๊ฐ๋ฅผ ์ ์ฐํ๊ฒ ์ฌ์ฉํ ์ ์๋๋ก ํ๋ฉด ๋ ์ข์ ๊ฒ ๊ฐ์์
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.
์ ๋ต๋ต!์๊ทธ๋๋ ํ ์คํธ ์ฝ๋ ์์ฑํ๋๋ฐ ๋ฆฌํฉํ ๋ง ํด์ผํ ๊ฒ์ผ๋ก ํ๋จ์ด ๋๋๋ผ๊ตฌ์ ์ฐธ๊ณ ํด์ ์์ ํ๊ฒ ์ต๋๋ค~!
@@ -63,9 +63,11 @@ protected void configure(HttpSecurity http) throws Exception { | |||
.antMatchers("/users/isAlreadyUsed").permitAll() | |||
.antMatchers("/css/**", "/js/**", "/webjars/**").permitAll() | |||
// TODO: Spring Security + JWT ์ธ์ฆ ๋ก์ง ์ถ๊ฐ | |||
.antMatchers("/**").permitAll() |
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.
์ด ์ค์ ์ ์ ์ฒด api๋ฅผ permit์์ผ์ฃผ๊ฒ ๋๋ ๊ฒ ์๋๊ฐ์??
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.
์ด๋จธ ์ ๊ฑฐ ์๋ชป ์ฌ๋ผ๊ฐ์ด์;; ๐ ์ด๊ฑฐ ์๊ทธ๋๋ ์์ ํด์ผํฉ๋๋ค;;
โฆlombok.config ํ์ผ ์ถ๊ฐ
-- ๐ ์๋น์ค ๋ชฉ๋ก --
๊ฒฝ๋งค ๊ฒฐ์ ์ ๋ณด ํ์ธ
๊ฒฐ์ ํ๊ธฐ
-- ๐ป ์ฌ์ฉ ๊ธฐ์ --
TossPay API
Redis Cache