Skip to content
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

[Spring MVC] 김나윤 미션 제출합니다. #298

Open
wants to merge 4 commits into
base: bbggr1209
Choose a base branch
from

Conversation

bbggr1209
Copy link

No description provided.

@sojeong0202
Copy link

열심히 한 거 같아용, 저보다 잘해서 리뷰하기 살짝 부끄럽네요🫣

간단하게 코멘트 남겼어요, 남은 미션도 파이팅!!

Comment on lines +6 to +13
@Controller
public class HomeController {

@GetMapping("/")
public String home() {
return "home";
}
}

Choose a reason for hiding this comment

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

목적에 따라 컨트롤러 분리한 거 좋아보여요 굿👍

Comment on lines +35 to +36
@GetMapping(value = "/reservations", produces = "application/json")
@ResponseBody

Choose a reason for hiding this comment

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

GetMappingproduces가 무슨 역할을 하는지 궁금해용🤓

Choose a reason for hiding this comment

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

produces는 무슨 역할을 하고 왜 썼는지 저도 궁금합니다 🧐

Comment on lines +3 to +20
public class ApiResponseTemplate<T> {

private final String status;
private final T data;

public ApiResponseTemplate(String status, T data) {
this.status = status;
this.data = data;
}

public String getStatus() {
return status;
}

public T getData() {
return data;
}
}

Choose a reason for hiding this comment

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

이런 식으로 API 응답에서 상태 코드와 실질적인 데이터를 분리할 수 있군요 굿👍

Comment on lines +79 to +85
@DeleteMapping("/reservations/{id}")
@ResponseBody
public ResponseEntity<ApiResponseTemplate<String>> deleteReservation(@PathVariable Long id) {
ensureReservationExists(id);
removeReservation(id);
return createSuccessDeleteResponse();
}

Choose a reason for hiding this comment

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

메소드 분리를 잘한 거 같아요🙂

Comment on lines +117 to +123
@PostMapping("/reservations/reset")
@ResponseBody
public ResponseEntity<Void> resetReservations() {
index.set(1);
reservations.clear();
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

Choose a reason for hiding this comment

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

모든 예약 삭제 API도 구현한 건가요? 열정적인 모습👍

Comment on lines 15 to 16
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD)

Choose a reason for hiding this comment

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

@SpringBootTest@DirtiesContext를 알고 계셨나요?
추가적으로 공부해서 알려주세용!🤓 (LBP 전체적인 숙제였읍니당,,,)

Comment on lines +35 to +36
@Test
void 이단계() {

Choose a reason for hiding this comment

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

@DisplayName을 이용해서 테스트 메소드의 목적을 명시해볼까요?
한 문장으로 표현되지 않는다면 테스트 메소드를 분리해봅시당

Comment on lines +3 to +6
public class BadRequestException extends IllegalArgumentException {
public BadRequestException(String message) {
super(message);
}

Choose a reason for hiding this comment

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

커스텀 예외 👍
커스텀 예외처리의 장점을 알려주세용👀


@PostMapping("/reservations")
@ResponseBody
public ResponseEntity<ApiResponseTemplate<ReservationResDto>> addReservation(@RequestBody ReservationReqDto reservationReqDto) {

Choose a reason for hiding this comment

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

ApiResponseTemplate로 따로 더 감싸서 응답하는 이유는 뭔가용?

import org.springframework.web.bind.annotation.ExceptionHandler;
import roomescape.template.ApiResponseTemplate;

@ControllerAdvice

Choose a reason for hiding this comment

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

@ControllerAdvice 어노테이션은 무슨 역할을 하나요?

Comment on lines +35 to +36
@GetMapping(value = "/reservations", produces = "application/json")
@ResponseBody

Choose a reason for hiding this comment

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

produces는 무슨 역할을 하고 왜 썼는지 저도 궁금합니다 🧐

@@ -0,0 +1,20 @@
package roomescape.template;

public class ApiResponseTemplate<T> {

Choose a reason for hiding this comment

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

클래스 ApiResponseTemplate<T>에 대해서 설명해주실 수 있나요?

class MissionStepTest {

@BeforeEach
void 초기화() {

Choose a reason for hiding this comment

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

초기화를 통해 테스트 환경을 일관되게 제공하려고 한 점 좋은 것 같습니다 굿

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.

4 participants