Skip to content

Conversation

@ZinYan
Copy link

@ZinYan ZinYan commented Nov 13, 2025

No description provided.

Copy link

@juanxiu juanxiu left a comment

Choose a reason for hiding this comment

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

고생하셨습니다~ 리뷰 반영해서 푸시 부탁드립니다~!

package roomescape;


public class Reservation{
Copy link

Choose a reason for hiding this comment

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

파일 경로를 변경해볼까요? /controller 와 /dto 를 분리하면 좋을 것 같습니다

return ResponseEntity.noContent().build();
}

// Exception Handler
Copy link

Choose a reason for hiding this comment

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

예외 클래스는 별도의 별도 패키지로 분리해주세요~!

// Exception Handler
public class NotFoundReservationException extends RuntimeException {}
public class BadRequestReservationException extends RuntimeException {}
@ExceptionHandler({BadRequestReservationException.class, NotFoundReservationException.class})
Copy link

Choose a reason for hiding this comment

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

NotFound 에러는 404 코드를 던지는 게 좋을 것 같아요! 현재는 Bad request 로 처리하고 있네요. 별도 메서드로 분리해볼까요?


// Create
@PostMapping("/reservations")
public ResponseEntity<Reservation> add_reservation(@RequestBody Reservation reservation){
Copy link

Choose a reason for hiding this comment

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

메서드명이 snake case 로 되어있네요.Java 컨벤션에서 메서드명은 camelCase 을 주로 사용합니다 :)

@PostMapping("/reservations")
public ResponseEntity<Reservation> add_reservation(@RequestBody Reservation reservation){
// handle exception -> any required field empty
if(isBlank(reservation.getName()) || isBlank(reservation.getDate()) || isBlank(reservation.getTime())){
Copy link

@juanxiu juanxiu Nov 23, 2025

Choose a reason for hiding this comment

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

파라미터 입력을 수동으로 검증을 하고 있네요. Valid 어노테이션을 사용해볼까요? 이 글 을 참고하면, DTO 의 필드 입력을 컨트롤러에서 검증하는 Valid 어노테이션 동작을 이해하는 데 도움될 것 같습니다!

return time;
}

public static Reservation toEntity(Reservation reservation,Long id){
Copy link

Choose a reason for hiding this comment

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

정적 팩토리 메서드는 엔티티와 DTO 가 분리되었을 때 객체 생성을 위해서 사용하는 메서드입니다. 현재는 DTO 만 존재하니 필요하지 않을 것 같습니다~

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.

2 participants