Repository navigation
[#29] 예약 조회 #32
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
Merged
Merged
[#29] 예약 조회 #32
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/com/ticketing/reservation/global/web/StrictLongBinding.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.ticketing.reservation.global.web; | ||
|
|
||
| import org.springframework.web.bind.WebDataBinder; | ||
| import org.springframework.web.bind.annotation.ControllerAdvice; | ||
| import org.springframework.web.bind.annotation.InitBinder; | ||
|
|
||
| @ControllerAdvice | ||
| public class StrictLongBinding { | ||
|
|
||
| @InitBinder | ||
| public void registerStrictLongEditor(WebDataBinder binder) { | ||
| binder.registerCustomEditor(Long.class, new StrictLongEditor()); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/ticketing/reservation/global/web/StrictLongEditor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.ticketing.reservation.global.web; | ||
|
|
||
| import java.beans.PropertyEditorSupport; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| public class StrictLongEditor extends PropertyEditorSupport { | ||
|
|
||
| private static final Pattern INTEGER = Pattern.compile("-?\\d+"); | ||
|
|
||
| @Override | ||
| public void setAsText(String text) { | ||
| if (!INTEGER.matcher(text).matches()) { | ||
| throw new IllegalArgumentException("정수 형식이 아닙니다. value=" + text); | ||
| } | ||
| setValue(Long.valueOf(text)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/com/ticketing/reservation/reservation/domain/ReservationDetail.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.ticketing.reservation.reservation.domain; | ||
|
|
||
| import com.ticketing.reservation.performance.domain.Performance; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| public record ReservationDetail( | ||
| Reservation reservation, Performance performance, ReservationStatus status) { | ||
|
|
||
| public LocalDateTime paymentDeadlineAt() { | ||
| if (status != ReservationStatus.PENDING_PAYMENT) { | ||
| return null; | ||
| } | ||
| return reservation.getPaymentDeadlineAt(); | ||
| } | ||
| } |
3 changes: 2 additions & 1 deletion
3
src/main/java/com/ticketing/reservation/reservation/domain/ReservationStatus.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package com.ticketing.reservation.reservation.domain; | ||
|
|
||
| public enum ReservationStatus { | ||
| PENDING_PAYMENT | ||
| PENDING_PAYMENT, | ||
| EXPIRED | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/ticketing/reservation/reservation/dto/PerformanceSummary.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.ticketing.reservation.reservation.dto; | ||
|
|
||
| import com.ticketing.reservation.performance.domain.Performance; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| public record PerformanceSummary(Long id, String title, String venue, LocalDateTime performanceAt) { | ||
|
|
||
| static PerformanceSummary from(Performance performance) { | ||
| return new PerformanceSummary( | ||
| performance.getId(), | ||
| performance.getTitle(), | ||
| performance.getVenue(), | ||
| performance.getPerformanceAt()); | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/ticketing/reservation/reservation/dto/ReservationDetailResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.ticketing.reservation.reservation.dto; | ||
|
|
||
| import static com.ticketing.reservation.reservation.dto.ReservationResponse.MICROS_PATTERN; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||
| import com.ticketing.reservation.reservation.domain.Reservation; | ||
| import com.ticketing.reservation.reservation.domain.ReservationDetail; | ||
| import com.ticketing.reservation.reservation.domain.ReservationStatus; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| public record ReservationDetailResponse( | ||
| Long id, | ||
| PerformanceSummary performance, | ||
| int quantity, | ||
| int unitPrice, | ||
| long totalPrice, | ||
| ReservationStatus status, | ||
| @JsonFormat(pattern = MICROS_PATTERN) LocalDateTime reservedAt, | ||
| @JsonFormat(pattern = MICROS_PATTERN) LocalDateTime paymentDeadlineAt) { | ||
|
|
||
| public static ReservationDetailResponse from(ReservationDetail detail) { | ||
| Reservation reservation = detail.reservation(); | ||
| return new ReservationDetailResponse( | ||
| reservation.getId(), | ||
| PerformanceSummary.from(detail.performance()), | ||
| reservation.getQuantity(), | ||
| reservation.getUnitPrice(), | ||
| reservation.getTotalPrice(), | ||
| detail.status(), | ||
| reservation.getReservedAt(), | ||
| detail.paymentDeadlineAt()); | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/ticketing/reservation/reservation/dto/ReservationListResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.ticketing.reservation.reservation.dto; | ||
|
|
||
| import static com.ticketing.reservation.reservation.dto.ReservationResponse.MICROS_PATTERN; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||
| import com.ticketing.reservation.performance.domain.Performance; | ||
| import com.ticketing.reservation.reservation.domain.Reservation; | ||
| import com.ticketing.reservation.reservation.domain.ReservationDetail; | ||
| import com.ticketing.reservation.reservation.domain.ReservationStatus; | ||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| public record ReservationListResponse(List<Item> reservations) { | ||
|
|
||
| public static ReservationListResponse from(List<ReservationDetail> details) { | ||
| return new ReservationListResponse(details.stream().map(Item::from).toList()); | ||
| } | ||
|
|
||
| public record Item( | ||
| Long id, | ||
| PerformanceItem performance, | ||
| int quantity, | ||
| long totalPrice, | ||
| ReservationStatus status, | ||
| @JsonFormat(pattern = MICROS_PATTERN) LocalDateTime paymentDeadlineAt) { | ||
|
|
||
| private static Item from(ReservationDetail detail) { | ||
| Reservation reservation = detail.reservation(); | ||
| return new Item( | ||
| reservation.getId(), | ||
| PerformanceItem.from(detail.performance()), | ||
| reservation.getQuantity(), | ||
| reservation.getTotalPrice(), | ||
| detail.status(), | ||
| detail.paymentDeadlineAt()); | ||
| } | ||
| } | ||
|
|
||
| public record PerformanceItem(Long id, String title, LocalDateTime performanceAt) { | ||
|
|
||
| private static PerformanceItem from(Performance performance) { | ||
| return new PerformanceItem( | ||
| performance.getId(), performance.getTitle(), performance.getPerformanceAt()); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.