-
Notifications
You must be signed in to change notification settings - Fork 82
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
[3 - 4단계 방탈출 예약 대기] 카피(김상혁) 미션 제출합니다. #107
Changes from 35 commits
9d1798e
f5047da
ae81820
f2b0572
a14d4ed
fa12a9b
711f902
f3921df
c34818a
105b664
61eff92
4ffdea9
f537c88
904e2b5
b8efcd6
300be37
b7cf143
aee0764
c68f262
94255cb
8af3ed5
2a92b00
f5234a0
8d5500d
2a06d47
71d23b4
4488375
952c1a6
dd60fc5
8f0f7bd
72340aa
e6922d2
90b837e
e30e447
91161ad
a1df0cf
a439eec
3e8fe2c
aeb44de
26b29a6
e3498d6
0ea3648
fa306e2
f4e466e
4ce74c0
17c2c6a
15083f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package roomescape.controller.api; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.Positive; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import roomescape.auth.AuthenticatedMember; | ||
import roomescape.domain.Member; | ||
import roomescape.domain.Reservation; | ||
import roomescape.domain.ReservationStatus; | ||
import roomescape.service.dto.request.ReservationSaveRequest; | ||
import roomescape.service.dto.response.ReservationResponse; | ||
import roomescape.service.reservation.ReservationCreateService; | ||
import roomescape.service.reservation.ReservationDeleteService; | ||
|
||
import java.net.URI; | ||
|
||
@RestController | ||
public class WaitingApiController { | ||
|
||
private final ReservationCreateService reservationCreateService; | ||
private final ReservationDeleteService reservationDeleteService; | ||
|
||
public WaitingApiController(ReservationCreateService reservationCreateService, | ||
ReservationDeleteService reservationDeleteService) { | ||
this.reservationCreateService = reservationCreateService; | ||
this.reservationDeleteService = reservationDeleteService; | ||
} | ||
|
||
@PostMapping("/api/waitings") | ||
public ResponseEntity<ReservationResponse> addWaiting(@AuthenticatedMember Member member, | ||
@RequestBody @Valid | ||
ReservationSaveRequest request) { | ||
Reservation newReservation = reservationCreateService.createReservation( | ||
request, | ||
member, | ||
ReservationStatus.WAITING | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. request에 status를 받는다면 이 api는 필요없지 않을까요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 status 외에 중복이기 때문에 클라이언트에서 해당 status 값을 request로 넘겨주는 방식으로 변경했습니다! |
||
); | ||
return ResponseEntity.created(URI.create("/api/waitings/" + newReservation.getId())) | ||
.body(new ReservationResponse(newReservation)); | ||
} | ||
|
||
@DeleteMapping("/api/waitings/{id}") | ||
public ResponseEntity<Void> deleteWaiting(@AuthenticatedMember Member member, | ||
@PathVariable | ||
@Positive(message = "1 이상의 값만 입력해주세요.") | ||
long id) { | ||
reservationDeleteService.deleteReservation(id, member); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wating이라는 도메인은 존재하지 않고 reservation으로 충분히 처리할 수 있을것 같아요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 Waiting이라는 엔티티가 존재하지 않기 때문에 엔드포인트에서 리소스로 관리하지 않도록 변경했습니다. |
||
} |
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.
파라미터는 어노테이션을 개행하면 어디에 적용하는지 쉽게 안보여서 한줄로 처리할 수 있도록 해주는게 좋을것 같아요!