diff --git a/app/api/show-api/src/main/java/com/example/show/service/ShowService.java b/app/api/show-api/src/main/java/com/example/show/service/ShowService.java index 1f122c5f..e4d64df1 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/ShowService.java +++ b/app/api/show-api/src/main/java/com/example/show/service/ShowService.java @@ -23,7 +23,6 @@ import java.time.LocalDateTime; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.UUID; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -75,13 +74,13 @@ public PaginationServiceResponse searchShow( public PaginationServiceResponse findShows( ShowPaginationServiceRequest request ) { - var response = showUseCase.findShows(request.toDomainRequest()); + LocalDateTime now = LocalDateTime.now(); + var response = showUseCase.findShows(request.toDomainRequest(now)); var data = response.data().stream() .map(domainResponse -> - ShowPaginationServiceResponse.of(domainResponse, request.onlyOpenSchedule()) + ShowPaginationServiceResponse.of(domainResponse, now) ) - .filter(Objects::nonNull) .toList(); return PaginationServiceResponse.of( diff --git a/app/api/show-api/src/main/java/com/example/show/service/dto/request/ShowPaginationServiceRequest.java b/app/api/show-api/src/main/java/com/example/show/service/dto/request/ShowPaginationServiceRequest.java index 4169cb4f..6bfdad76 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/dto/request/ShowPaginationServiceRequest.java +++ b/app/api/show-api/src/main/java/com/example/show/service/dto/request/ShowPaginationServiceRequest.java @@ -1,6 +1,7 @@ package com.example.show.service.dto.request; import com.example.show.controller.vo.ShowSortApiType; +import java.time.LocalDateTime; import java.util.UUID; import lombok.Builder; import org.example.dto.show.request.ShowPaginationDomainRequest; @@ -13,12 +14,13 @@ public record ShowPaginationServiceRequest( int size ) { - public ShowPaginationDomainRequest toDomainRequest() { + public ShowPaginationDomainRequest toDomainRequest(LocalDateTime now) { return ShowPaginationDomainRequest.builder() .sort(sort.toDomainType()) .onlyOpenSchedule(onlyOpenSchedule) .cursorId(cursorId) .size(size) + .now(now) .build(); } } diff --git a/app/api/show-api/src/main/java/com/example/show/service/dto/response/ShowPaginationServiceResponse.java b/app/api/show-api/src/main/java/com/example/show/service/dto/response/ShowPaginationServiceResponse.java index b6b7b6b5..9f4d544f 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/dto/response/ShowPaginationServiceResponse.java +++ b/app/api/show-api/src/main/java/com/example/show/service/dto/response/ShowPaginationServiceResponse.java @@ -1,6 +1,5 @@ package com.example.show.service.dto.response; -import java.time.LocalDate; import java.time.LocalDateTime; import java.util.UUID; import lombok.Builder; @@ -17,18 +16,8 @@ public record ShowPaginationServiceResponse( ) { public static ShowPaginationServiceResponse of( ShowTicketingDomainResponse response, - boolean onlyOpenSchedule + LocalDateTime now ) { - LocalDateTime now = LocalDateTime.now(); - - if (onlyOpenSchedule && response.ticketingAt().isBefore(now)) { - return null; - } - - if (!onlyOpenSchedule && response.endDate().isBefore(LocalDate.now())) { - return null; - } - return ShowPaginationServiceResponse.builder() .id(response.id()) .title(response.title()) diff --git a/app/domain/show-domain/src/main/java/org/example/repository/show/ShowQuerydslRepositoryImpl.java b/app/domain/show-domain/src/main/java/org/example/repository/show/ShowQuerydslRepositoryImpl.java index abb1b2b7..9b0e299d 100644 --- a/app/domain/show-domain/src/main/java/org/example/repository/show/ShowQuerydslRepositoryImpl.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/show/ShowQuerydslRepositoryImpl.java @@ -18,6 +18,7 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; @@ -152,6 +153,12 @@ public long findTerminatedTicketingShowsCount(List showIds, LocalDateTime private Predicate getShowAlertsInCursorPagination(ShowPaginationDomainRequest request) { BooleanExpression wherePredicate = getDefaultPredicateExpression(); + if (request.onlyOpenSchedule()) { + return wherePredicate.and(showTicketingTime.ticketingAt.after(request.now())); + } else { + wherePredicate.and(show.endDate.after(LocalDate.now())); + } + if (request.cursorId() == null) { return wherePredicate; }