diff --git a/app/api/show-api/src/main/java/com/example/show/service/UserShowService.java b/app/api/show-api/src/main/java/com/example/show/service/UserShowService.java index ca94406c..6c7d7cf1 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/UserShowService.java +++ b/app/api/show-api/src/main/java/com/example/show/service/UserShowService.java @@ -145,7 +145,7 @@ public TicketingAlertReservationServiceResponse findAlertsReservations( } public NumberOfTicketingAlertServiceResponse countAlertShows(UUID userId, LocalDateTime now) { - long numberOfTicketingAlert = interestShowUseCase.countAlertShows(userId, now); + long numberOfTicketingAlert = ticketingAlertUseCase.countAlertShows(userId, now); return NumberOfTicketingAlertServiceResponse.from(numberOfTicketingAlert); } diff --git a/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepository.java b/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepository.java index 8e891acc..afdbed88 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepository.java +++ b/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepository.java @@ -1,13 +1,11 @@ package org.example.repository.interest; -import java.time.LocalDateTime; -import java.util.UUID; import org.example.dto.request.InterestShowPaginationDomainRequest; import org.example.dto.response.InterestShowPaginationDomainResponse; public interface InterestShowQuerydslRepository { - InterestShowPaginationDomainResponse findInterestShowList(InterestShowPaginationDomainRequest request); - - long countValidTicketingAlerts(UUID userId, LocalDateTime now); + InterestShowPaginationDomainResponse findInterestShowList( + InterestShowPaginationDomainRequest request + ); } diff --git a/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java b/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java index 2c3c9010..465ed1ed 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java +++ b/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java @@ -1,12 +1,9 @@ package org.example.repository.interest; import static org.example.entity.QInterestShow.interestShow; -import static org.example.entity.QTicketingAlert.ticketingAlert; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; -import java.time.LocalDateTime; -import java.util.UUID; import lombok.RequiredArgsConstructor; import org.example.dto.request.InterestShowPaginationDomainRequest; import org.example.dto.response.InterestShowPaginationDomainResponse; @@ -42,21 +39,9 @@ public InterestShowPaginationDomainResponse findInterestShowList( .build(); } - @Override - public long countValidTicketingAlerts(UUID userId, LocalDateTime now) { - Long result = jpaQueryFactory.select(ticketingAlert.showId.countDistinct()) - .from(ticketingAlert) - .where( - ticketingAlert.isDeleted.isFalse() - .and(ticketingAlert.userId.eq(userId)) - .and(ticketingAlert.alertTime.gt(now)) - ) - .fetchOne(); - - return result == null ? 0 : result; - } - - private BooleanExpression getInterestShowPaginationConditions(InterestShowPaginationDomainRequest request) { + private BooleanExpression getInterestShowPaginationConditions( + InterestShowPaginationDomainRequest request + ) { BooleanExpression whereConditions = interestShow.userId.eq(request.userId()) .and(interestShow.isDeleted.isFalse()); diff --git a/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepository.java b/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepository.java index 7737e38b..439bac10 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepository.java +++ b/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepository.java @@ -1,5 +1,9 @@ package org.example.repository.ticketing; +import java.time.LocalDateTime; +import java.util.UUID; + public interface TicketingAlertQuerydslRepository { + long countValidTicketingAlerts(UUID userId, LocalDateTime now); } diff --git a/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepositoryImpl.java b/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepositoryImpl.java index e499a01f..0633965f 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepositoryImpl.java +++ b/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepositoryImpl.java @@ -1,6 +1,10 @@ package org.example.repository.ticketing; +import static org.example.entity.QTicketingAlert.ticketingAlert; + import com.querydsl.jpa.impl.JPAQueryFactory; +import java.time.LocalDateTime; +import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; @@ -10,4 +14,17 @@ public class TicketingAlertQuerydslRepositoryImpl implements TicketingAlertQuery private final JPAQueryFactory jpaQueryFactory; + @Override + public long countValidTicketingAlerts(UUID userId, LocalDateTime now) { + Long result = jpaQueryFactory.select(ticketingAlert.showId.countDistinct()) + .from(ticketingAlert) + .where( + ticketingAlert.isDeleted.isFalse() + .and(ticketingAlert.userId.eq(userId)) + .and(ticketingAlert.alertTime.gt(now)) + ) + .fetchOne(); + + return result == null ? 0 : result; + } } diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/interest/InterestShowUseCase.java b/app/domain/user-domain/src/main/java/org/example/usecase/interest/InterestShowUseCase.java index ade1a755..d134d0c2 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/interest/InterestShowUseCase.java +++ b/app/domain/user-domain/src/main/java/org/example/usecase/interest/InterestShowUseCase.java @@ -1,6 +1,5 @@ package org.example.usecase.interest; -import java.time.LocalDateTime; import java.util.Optional; import java.util.UUID; import lombok.RequiredArgsConstructor; @@ -20,7 +19,10 @@ public class InterestShowUseCase { @Transactional public InterestShow interest(InterestShowDomainRequest request) { - Optional optInterestShow = findInterestShowByShowIdAndUserId(request.showId(), request.userId()); + Optional optInterestShow = findInterestShowByShowIdAndUserId( + request.showId(), + request.userId() + ); if (optInterestShow.isEmpty()) { return interestShowRepository.save( @@ -46,10 +48,6 @@ public InterestShowPaginationDomainResponse findInterestShows( return interestShowRepository.findInterestShowList(request); } - public long countAlertShows(UUID userId, LocalDateTime now) { - return interestShowRepository.countValidTicketingAlerts(userId, now); - } - public long countInterestShows(UUID userId) { Long result = interestShowRepository.countInterestShowByUserIdAndIsDeletedFalse(userId); return result == null ? 0 : result; diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/ticketing/TicketingAlertUseCase.java b/app/domain/user-domain/src/main/java/org/example/usecase/ticketing/TicketingAlertUseCase.java index e2be7f5d..5653e8f0 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/ticketing/TicketingAlertUseCase.java +++ b/app/domain/user-domain/src/main/java/org/example/usecase/ticketing/TicketingAlertUseCase.java @@ -34,6 +34,10 @@ public List findTicketingAlertsByUserId(UUID userId) { return ticketingAlertRepository.findAllByUserIdAndIsDeletedFalse(userId); } + public long countAlertShows(UUID userId, LocalDateTime now) { + return ticketingAlertRepository.countValidTicketingAlerts(userId, now); + } + @Transactional public TicketingAlertsDomainResponse alertReservation( TicketingAlertReservationDomainRequest ticketingAlertReservation