diff --git a/app/api/show-api/src/main/java/com/example/show/error/ShowError.java b/app/api/show-api/src/main/java/com/example/show/error/ShowError.java index e40be098..6abb3754 100644 --- a/app/api/show-api/src/main/java/com/example/show/error/ShowError.java +++ b/app/api/show-api/src/main/java/com/example/show/error/ShowError.java @@ -4,10 +4,10 @@ public enum ShowError implements BusinessError { - ENTITY_NOT_FOUND { + TICKETING_ALERT_RESERVED_ERROR { @Override public int getHttpStatus() { - return 404; + return 400; } @Override @@ -17,12 +17,12 @@ public String getErrorCode() { @Override public String getClientMessage() { - return "해당 공연을 찾을 수 없습니다."; + return "해당 공연의 티켓팅 알림을 설정할 수 없습니다."; } @Override public String getLogMessage() { - return "공연 ID에 매칭되는 정보를 찾을 수 없습니다."; + return "해당 공연의 티켓팅 시간에 설정할 수 있는 알림 시간이 없습니다."; } } } 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 3c8a9870..f6c22e79 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 @@ -4,6 +4,7 @@ import com.example.publish.MessagePublisher; import com.example.publish.message.TicketingAlertsToReserveServiceMessage; import com.example.show.controller.vo.TicketingApiType; +import com.example.show.error.ShowError; import com.example.show.service.dto.param.ShowAlertPaginationServiceParam; import com.example.show.service.dto.param.ShowSearchPaginationServiceParam; import com.example.show.service.dto.request.InterestShowPaginationServiceRequest; @@ -33,6 +34,7 @@ import org.example.entity.TicketingAlert; import org.example.entity.show.Show; import org.example.entity.show.ShowTicketingTime; +import org.example.exception.BusinessException; import org.example.usecase.TicketingAlertUseCase; import org.example.usecase.UserShowUseCase; import org.example.usecase.show.ShowUseCase; @@ -52,7 +54,7 @@ public ShowDetailServiceResponse getShow(UUID userId, UUID showId, String viewId ShowDetailDomainResponse showDetail = showUseCase.findShowDetail(showId); boolean isInterested = - userId != null && userShowUseCase.findByShowIdAndUserId(showId, userId).isPresent(); + userId != null && userShowUseCase.findInterestShow(showId, userId).isPresent(); if (viewCountComponent.validateViewCount(showId, viewIdentifier)) { showUseCase.view(showId); @@ -111,8 +113,10 @@ public PaginationServiceResponse findInte } public ShowInterestServiceResponse interest(ShowInterestServiceRequest request) { + Show show = showUseCase.findShowOrThrowNoSuchElementException(request.showId()); + return ShowInterestServiceResponse.from( - userShowUseCase.interest(request.toDomainRequest()) + userShowUseCase.interest(request.toDomainRequest(show.getId())) ); } @@ -147,13 +151,16 @@ public void alertReservation( ticketingAlertReservationRequest.type().toDomainType() ); - var domainResponse = ticketingAlertUseCase.alertReservation( - ticketingAlertReservationRequest.toDomainRequest( - showTicketingTime.getShow().getTitle(), - showTicketingTime.getTicketingAt() - ) + var request = ticketingAlertReservationRequest.toDomainRequest( + showTicketingTime.getShow().getTitle(), + showTicketingTime.getTicketingAt() ); + if (request.alertTimes().isEmpty()) { + throw new BusinessException(ShowError.TICKETING_ALERT_RESERVED_ERROR); + } + + var domainResponse = ticketingAlertUseCase.alertReservation(request); messagePublisher.publishTicketingReservation( "ticketingAlert", TicketingAlertsToReserveServiceMessage.from(domainResponse) diff --git a/app/api/show-api/src/main/java/com/example/show/service/dto/request/ShowInterestServiceRequest.java b/app/api/show-api/src/main/java/com/example/show/service/dto/request/ShowInterestServiceRequest.java index 4ee02cce..8309ef8e 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/dto/request/ShowInterestServiceRequest.java +++ b/app/api/show-api/src/main/java/com/example/show/service/dto/request/ShowInterestServiceRequest.java @@ -10,9 +10,9 @@ public record ShowInterestServiceRequest( UUID userId ) { - public InterestShowDomainRequest toDomainRequest() { + public InterestShowDomainRequest toDomainRequest(UUID showId) { return InterestShowDomainRequest.builder() - .showId(showId()) + .showId(showId) .userId(userId()) .build(); } diff --git a/app/api/show-api/src/main/java/com/example/show/service/dto/response/InterestShowPaginationServiceResponse.java b/app/api/show-api/src/main/java/com/example/show/service/dto/response/InterestShowPaginationServiceResponse.java index bd0bd5c7..955ed580 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/dto/response/InterestShowPaginationServiceResponse.java +++ b/app/api/show-api/src/main/java/com/example/show/service/dto/response/InterestShowPaginationServiceResponse.java @@ -28,7 +28,7 @@ public static InterestShowPaginationServiceResponse from( .interestShowId(interestShow.getId()) .interestedAt(interestShow.getUpdatedAt()) .title(show.getTitle()) - .location(show.getTitle()) + .location(show.getLocation()) .posterImageURL(show.getImage()) .startAt(show.getStartDate()) .endAt(show.getEndDate()) diff --git a/app/domain/show-domain/src/main/java/org/example/repository/show/ShowRepository.java b/app/domain/show-domain/src/main/java/org/example/repository/show/ShowRepository.java index da8a7de4..a0ac3dbf 100644 --- a/app/domain/show-domain/src/main/java/org/example/repository/show/ShowRepository.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/show/ShowRepository.java @@ -1,6 +1,7 @@ package org.example.repository.show; import java.util.List; +import java.util.Optional; import java.util.UUID; import org.example.entity.show.Show; import org.springframework.data.jpa.repository.JpaRepository; @@ -8,4 +9,6 @@ public interface ShowRepository extends JpaRepository, ShowQuerydslRepository { List findShowsByIdIn(List showIds); + + Optional findByIdAndIsDeletedFalse(UUID showId); } diff --git a/app/domain/show-domain/src/main/java/org/example/usecase/show/ShowUseCase.java b/app/domain/show-domain/src/main/java/org/example/usecase/show/ShowUseCase.java index e1b4aee5..66bb0026 100644 --- a/app/domain/show-domain/src/main/java/org/example/usecase/show/ShowUseCase.java +++ b/app/domain/show-domain/src/main/java/org/example/usecase/show/ShowUseCase.java @@ -78,7 +78,7 @@ public long findTerminatedTicketingShowsCount(List showIds, LocalDateTime return showRepository.findTerminatedTicketingShowsCount(showIds, now); } - private Show findShowOrThrowNoSuchElementException(UUID id) { - return showRepository.findById(id).orElseThrow(NoSuchElementException::new); + public Show findShowOrThrowNoSuchElementException(UUID id) { + return showRepository.findByIdAndIsDeletedFalse(id).orElseThrow(NoSuchElementException::new); } } diff --git a/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowRepository.java b/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowRepository.java index 3f15bf23..d0cf11c4 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowRepository.java +++ b/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowRepository.java @@ -9,5 +9,7 @@ public interface InterestShowRepository extends JpaRepository findByShowIdAndUserId(UUID showId, UUID userId); + Optional findByShowIdAndUserIdAndIsDeletedFalse(UUID showId, UUID userId); + Long countInterestShowByUserIdAndIsDeletedFalse(UUID userId); } diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/UserShowUseCase.java b/app/domain/user-domain/src/main/java/org/example/usecase/UserShowUseCase.java index f68921ce..7f600e91 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/UserShowUseCase.java +++ b/app/domain/user-domain/src/main/java/org/example/usecase/UserShowUseCase.java @@ -26,7 +26,7 @@ public class UserShowUseCase { @Transactional public InterestShow interest(InterestShowDomainRequest request) { - Optional optInterestShow = findByShowIdAndUserId(request.showId(), request.userId()); + Optional optInterestShow = findInterestShowByShowIdAndUserId(request.showId(), request.userId()); if (optInterestShow.isEmpty()) { return interestShowRepository.save( @@ -43,8 +43,8 @@ public InterestShow interest(InterestShowDomainRequest request) { return interestShow; } - public Optional findByShowIdAndUserId(UUID showId, UUID userId) { - return interestShowRepository.findByShowIdAndUserId(showId, userId); + public Optional findInterestShow(UUID showId, UUID userId) { + return interestShowRepository.findByShowIdAndUserIdAndIsDeletedFalse(showId, userId); } public List findArtistSubscriptionByUserId(UUID userId) { @@ -73,4 +73,8 @@ public long countInterestShows(UUID userId) { Long result = interestShowRepository.countInterestShowByUserIdAndIsDeletedFalse(userId); return result == null ? 0 : result; } + + private Optional findInterestShowByShowIdAndUserId(UUID showId, UUID userId) { + return interestShowRepository.findByShowIdAndUserId(showId, userId); + } }