-
Notifications
You must be signed in to change notification settings - Fork 84
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
[4 - 9단계 방탈출 예약 관리] 로빈(임수빈) 미션 제출합니다. #155
Changes from all commits
ffe11dc
4e47c32
1234c01
3f11120
71ad3fc
ac73aea
5997b65
ed2abfe
00eb67f
91824dd
3cc4e18
96df623
0a25fd6
749d788
7418291
6a7413d
fe28aa4
5d6b6ad
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,38 @@ | ||
package roomescape.controller; | ||
|
||
import java.util.List; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
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.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import roomescape.dto.ReservationTimeRequest; | ||
import roomescape.dto.ReservationTimeResponse; | ||
import roomescape.service.ReservationTimeService; | ||
|
||
@RestController | ||
@RequestMapping("/times") | ||
public class ReservationTimeController { | ||
private final ReservationTimeService reservationTimeService; | ||
|
||
public ReservationTimeController(ReservationTimeService reservationTimeService) { | ||
this.reservationTimeService = reservationTimeService; | ||
} | ||
|
||
@PostMapping | ||
public ReservationTimeResponse save(@RequestBody ReservationTimeRequest reservationTimeRequest) { | ||
return reservationTimeService.save(reservationTimeRequest); | ||
} | ||
|
||
@GetMapping | ||
public List<ReservationTimeResponse> findAll() { | ||
return reservationTimeService.findAll(); | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
public void delete(@PathVariable long id) { | ||
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.
상태코드에 대해서 참고자료를 보셨었나요? 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.
결론 : LMS 내의 오타(?)가 굴린 스노우볼이었다. 이런식으로 테스트 코드를 제공해 줬는데요, 지금은 LMS가 수정되었지만 PR 보내는 시점에만 해도 테스트 코드에서 상태 코드를 검증하는 부분이 API 명세와는 다르게 200이 아닌 특화된 상태코드였습니다. 이마저도 다음 단계 설명에서 제공해주는 테스트코드는 또 200으로 검증하기도 했습니다... 이 부분을 코치님들한테 여쭤보았을 때 모호하게 대답해주셔서 그저 200 으로 지정했습니다. |
||
reservationTimeService.delete(id); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package roomescape.domain; | ||
|
||
import java.time.LocalTime; | ||
import java.util.Objects; | ||
|
||
public class ReservationTime { | ||
private final Long id; | ||
private final LocalTime startAt; | ||
|
||
public ReservationTime(LocalTime startAt) { | ||
this(null, startAt); | ||
} | ||
|
||
public ReservationTime(Long id, LocalTime startAt) { | ||
this.id = id; | ||
this.startAt = startAt; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public LocalTime getStartAt() { | ||
return startAt; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = id != null ? id.hashCode() : 0; | ||
result = 31 * result + (startAt != null ? startAt.hashCode() : 0); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
ReservationTime that = (ReservationTime) o; | ||
|
||
if (!Objects.equals(id, that.id)) { | ||
return false; | ||
} | ||
return Objects.equals(startAt, that.startAt); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ReservationTime{" + | ||
"id=" + id + | ||
", startAt=" + startAt + | ||
'}'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package roomescape.dto; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
|
||
public record ReservationRequest(LocalDate date, String name, LocalTime time) { | ||
public record ReservationRequest(LocalDate date, String name, long timeId) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package roomescape.dto; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
|
||
public record ReservationResponse(long id, String name, LocalDate date, LocalTime time) { | ||
public record ReservationResponse(long id, String name, LocalDate date, ReservationTimeResponse time) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package roomescape.dto; | ||
|
||
import java.time.LocalTime; | ||
|
||
public record ReservationTimeRequest(LocalTime startAt) { | ||
} |
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.
요기엔 id로만 써주셨네요!
어느방향이든 일관성을 맞춰주세요