-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5eb88e4
commit 7aff7b5
Showing
12 changed files
with
145 additions
and
181 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
62 changes: 22 additions & 40 deletions
62
...pi/src/main/java/com/example/show/service/dto/response/ShowPaginationServiceResponse.java
This file contains 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,59 +1,41 @@ | ||
package com.example.show.service.dto.response; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
import lombok.Builder; | ||
import org.example.dto.show.response.ShowDetailDomainResponse; | ||
import org.example.util.DateTimeUtil; | ||
import org.example.dto.show.response.ShowTicketingDomainResponse; | ||
|
||
@Builder | ||
public record ShowPaginationServiceResponse( | ||
UUID id, | ||
String title, | ||
LocalDateTime ticketingAt, | ||
String location, | ||
String posterImageURL, | ||
String reservationAt, | ||
boolean hasTicketingOpenSchedule, | ||
int viewCount, | ||
List<ShowArtistSimpleServiceResponse> artists, | ||
List<ShowGenreSimpleServiceResponse> genres, | ||
List<ShowTicketingTimeServiceParam> showTicketingTimes | ||
String image, | ||
boolean isOpen | ||
) { | ||
public static ShowPaginationServiceResponse of( | ||
ShowTicketingDomainResponse response, | ||
boolean onlyOpenSchedule | ||
) { | ||
LocalDateTime now = LocalDateTime.now(); | ||
|
||
public static ShowPaginationServiceResponse from(ShowDetailDomainResponse response, LocalDateTime now) { | ||
List<ShowTicketingTimeServiceParam> ticketingTimes = response.showTicketingTimes().stream() | ||
.map(ShowTicketingTimeServiceParam::from) | ||
.toList(); | ||
if (onlyOpenSchedule && response.ticketingAt().isBefore(now)) { | ||
return null; | ||
} | ||
|
||
Optional<ShowTicketingTimeServiceParam> optShowTicketingTime = ticketingTimes.stream() | ||
.filter(ticketingTime -> now.isBefore(ticketingTime.ticketingAt())) | ||
.findFirst(); | ||
|
||
String reservationAt = optShowTicketingTime.map( | ||
showTicketingTime -> DateTimeUtil.formatDateTime(showTicketingTime.ticketingAt()) | ||
).orElseGet(() -> ""); | ||
if (!onlyOpenSchedule && response.endDate().isBefore(LocalDate.now())) { | ||
return null; | ||
} | ||
|
||
return ShowPaginationServiceResponse.builder() | ||
.id(response.show().id()) | ||
.title(response.show().title()) | ||
.location(response.show().location()) | ||
.posterImageURL(response.show().image()) | ||
.reservationAt(reservationAt) | ||
.hasTicketingOpenSchedule(now.isBefore(response.show().lastTicketingAt())) | ||
.viewCount(response.show().viewCount()) | ||
.artists( | ||
response.artists().stream() | ||
.map(ShowArtistSimpleServiceResponse::from) | ||
.toList() | ||
) | ||
.genres( | ||
response.genres().stream() | ||
.map(ShowGenreSimpleServiceResponse::from) | ||
.toList() | ||
) | ||
.showTicketingTimes(ticketingTimes) | ||
.id(response.id()) | ||
.title(response.title()) | ||
.ticketingAt(response.ticketingAt()) | ||
.location(response.location()) | ||
.image(response.image()) | ||
.isOpen(response.ticketingAt().isBefore(now)) | ||
.build(); | ||
} | ||
} |
This file contains 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
16 changes: 16 additions & 0 deletions
16
.../show-domain/src/main/java/org/example/dto/show/response/ShowTicketingDomainResponse.java
This file contains 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,16 @@ | ||
package org.example.dto.show.response; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.UUID; | ||
|
||
public record ShowTicketingDomainResponse( | ||
UUID id, | ||
String title, | ||
LocalDate endDate, | ||
LocalDateTime ticketingAt, | ||
String location, | ||
String image | ||
) { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...in/src/main/java/org/example/dto/show/response/ShowTicketingPaginationDomainResponse.java
This file contains 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,12 @@ | ||
package org.example.dto.show.response; | ||
|
||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record ShowTicketingPaginationDomainResponse( | ||
List<ShowTicketingDomainResponse> data, | ||
boolean hasNext | ||
) { | ||
|
||
} |
This file contains 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
Oops, something went wrong.