From 32af59eb0c305c65b48e1e923a639fb83463ce26 Mon Sep 17 00:00:00 2001 From: JunsuPark Date: Sun, 15 Sep 2024 22:32:13 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20user-show=20=EA=B4=80=EC=8B=AC?= =?UTF-8?q?=EC=82=AC=20=EC=9D=B4=EB=8F=99=20(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/showpot-dev-ci.yml | 1 + app/api/build.gradle | 1 + .../artist/controller/ArtistController.java | 13 ++ .../NumberOfSubscribedArtistApiResponse.java | 15 ++ .../artist/service/ArtistAdminService.java | 2 +- .../example/artist/service/ArtistService.java | 16 +- ...mberOfSubscribedArtistServiceResponse.java | 2 +- .../genre/controller/GenreController.java | 13 ++ .../NumberOfSubscribedGenreApiResponse.java | 15 ++ .../genre/service/GenreAdminService.java | 2 +- .../example/genre/service/GenreService.java | 15 +- ...umberOfSubscribedGenreServiceResponse.java | 2 +- .../publish/message/ArtistServiceMessage.java | 2 +- .../publish/message/GenreServiceMessage.java | 2 +- ...icketingAlertsToReserveServiceMessage.java | 9 +- .../message/TicketingTimeServiceMessage.java | 2 +- .../show/controller/ShowController.java | 123 ------------ .../show/controller/UserShowController.java | 176 ++++++++++++++++++ .../NumberOfInterestShowApiResponse.java | 15 ++ .../NumberOfTicketingAlertApiResponse.java | 15 ++ .../vo/TicketingAlertTimeApiType.java | 4 +- .../show/service/ShowAdminService.java | 6 +- .../com/example/show/service/ShowService.java | 136 +------------- .../example/show/service/UserShowService.java | 165 ++++++++++++++++ .../InterestShowPaginationServiceRequest.java | 2 +- .../request/ShowInterestServiceRequest.java | 2 +- ...cketingAlertReservationServiceRequest.java | 2 +- ...InterestShowPaginationServiceResponse.java | 2 +- .../response/ShowInterestServiceResponse.java | 2 +- ...ketingAlertReservationServiceResponse.java | 2 +- .../NumberOfInterestShowServiceResponse.java | 2 +- ...NumberOfTicketingAlertServiceResponse.java | 2 +- .../service/ArtistAdminServiceTest.java | 2 +- .../artist/service/ArtistServiceTest.java | 9 +- .../java/genre/service/GenreServiceTest.java | 6 +- .../show/service/ShowAdminServiceTest.java | 6 +- .../java/show/service/ShowServiceTest.java | 14 +- app/api/user-api/build.gradle | 2 +- .../controller/UserShowController.java | 75 -------- .../NumberOfInterestShowApiResponse.java | 12 -- .../NumberOfSubscribedArtistApiResponse.java | 12 -- .../NumberOfSubscribedGenreApiResponse.java | 12 -- .../NumberOfTicketingAlertApiResponse.java | 12 -- .../java/org/example/service/UserService.java | 22 ++- .../org/example/service/UserShowService.java | 42 ----- .../org/example/service/UserServiceTest.java | 17 +- .../org/example/config/ShowDomainConfig.java | 5 +- .../request/InterestShowDomainRequest.java | 2 +- .../InterestShowPaginationDomainRequest.java | 2 +- ...icketingAlertReservationDomainRequest.java | 2 +- .../InterestShowPaginationDomainResponse.java | 4 +- .../TicketingAlertsDomainResponse.java | 4 +- .../response/TicketingTimeDomainResponse.java | 2 +- .../entity/usershow}/ArtistSubscription.java | 3 +- .../entity/usershow}/GenreSubscription.java | 3 +- .../entity/usershow}/InterestShow.java | 3 +- .../entity/usershow}/TicketingAlert.java | 3 +- .../InterestShowQuerydslRepository.java | 11 ++ .../InterestShowQuerydslRepositoryImpl.java | 30 +-- .../interest/InterestShowRepository.java | 2 +- .../ArtistSubscriptionQuerydslRepository.java | 2 +- ...istSubscriptionQuerydslRepositoryImpl.java | 5 +- .../ArtistSubscriptionRepository.java | 2 +- .../GenreSubscriptionQuerydslRepository.java | 2 +- ...nreSubscriptionQuerydslRepositoryImpl.java | 8 +- .../GenreSubscriptionRepository.java | 3 +- .../TicketingAlertQuerydslRepository.java | 9 + .../TicketingAlertQuerydslRepositoryImpl.java | 31 +++ .../ticketing/TicketingAlertRepository.java | 3 +- .../usecase/ArtistSubscriptionUseCase.java | 16 +- .../usecase/{artist => }/ArtistUseCase.java | 2 +- .../usecase/GenreSubscriptionUseCase.java | 11 +- .../usecase/{genre => }/GenreUseCase.java | 2 +- .../example/usecase/InterestShowUseCase.java} | 47 ++--- .../usecase/{show => }/ShowAdminUseCase.java | 2 +- .../usecase/{show => }/ShowUseCase.java | 2 +- .../usecase/TicketingAlertUseCase.java | 24 +-- .../org/example/vo/TicketingAlertTime.java | 6 +- .../domain}/ArtistSubscriptionFixture.java | 4 +- .../domain}/GenreSubscriptionFixture.java | 4 +- .../org/example/config/UserDomainConfig.java | 6 +- .../InterestShowQuerydslRepository.java | 13 -- .../TicketingAlertQuerydslRepository.java | 5 - .../TicketingAlertQuerydslRepositoryImpl.java | 13 -- .../java/org/example/usecase/UserUseCase.java | 22 +-- .../java/org/example/vo/TicketingType.java | 8 - 86 files changed, 692 insertions(+), 647 deletions(-) create mode 100644 app/api/show-api/src/main/java/com/example/artist/controller/dto/response/NumberOfSubscribedArtistApiResponse.java rename app/api/{user-api/src/main/java/org/example => show-api/src/main/java/com/example/artist}/service/dto/response/NumberOfSubscribedArtistServiceResponse.java (82%) create mode 100644 app/api/show-api/src/main/java/com/example/genre/controller/dto/response/NumberOfSubscribedGenreApiResponse.java rename app/api/{user-api/src/main/java/org/example => show-api/src/main/java/com/example/genre}/service/dto/response/NumberOfSubscribedGenreServiceResponse.java (82%) create mode 100644 app/api/show-api/src/main/java/com/example/show/controller/UserShowController.java create mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/usershow/response/NumberOfInterestShowApiResponse.java create mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/usershow/response/NumberOfTicketingAlertApiResponse.java create mode 100644 app/api/show-api/src/main/java/com/example/show/service/UserShowService.java rename app/api/{user-api/src/main/java/org/example/service/dto => show-api/src/main/java/com/example/show/service/dto/usershow}/response/NumberOfInterestShowServiceResponse.java (79%) rename app/api/{user-api/src/main/java/org/example/service/dto => show-api/src/main/java/com/example/show/service/dto/usershow}/response/NumberOfTicketingAlertServiceResponse.java (79%) delete mode 100644 app/api/user-api/src/main/java/org/example/controller/UserShowController.java delete mode 100644 app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfInterestShowApiResponse.java delete mode 100644 app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfSubscribedArtistApiResponse.java delete mode 100644 app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfSubscribedGenreApiResponse.java delete mode 100644 app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfTicketingAlertApiResponse.java delete mode 100644 app/api/user-api/src/main/java/org/example/service/UserShowService.java rename app/domain/{user-domain/src/main/java/org/example/dto => show-domain/src/main/java/org/example/dto/usershow}/request/InterestShowDomainRequest.java (76%) rename app/domain/{user-domain/src/main/java/org/example/dto => show-domain/src/main/java/org/example/dto/usershow}/request/InterestShowPaginationDomainRequest.java (84%) rename app/domain/{user-domain/src/main/java/org/example/dto => show-domain/src/main/java/org/example/dto/usershow}/request/TicketingAlertReservationDomainRequest.java (90%) rename app/domain/{user-domain/src/main/java/org/example/dto => show-domain/src/main/java/org/example/dto/usershow}/response/InterestShowPaginationDomainResponse.java (64%) rename app/domain/{user-domain/src/main/java/org/example/dto => show-domain/src/main/java/org/example/dto/usershow}/response/TicketingAlertsDomainResponse.java (81%) rename app/domain/{user-domain/src/main/java/org/example/dto => show-domain/src/main/java/org/example/dto/usershow}/response/TicketingTimeDomainResponse.java (92%) rename app/domain/{user-domain/src/main/java/org/example/entity => show-domain/src/main/java/org/example/entity/usershow}/ArtistSubscription.java (91%) rename app/domain/{user-domain/src/main/java/org/example/entity => show-domain/src/main/java/org/example/entity/usershow}/GenreSubscription.java (91%) rename app/domain/{user-domain/src/main/java/org/example/entity => show-domain/src/main/java/org/example/entity/usershow}/InterestShow.java (92%) rename app/domain/{user-domain/src/main/java/org/example/entity => show-domain/src/main/java/org/example/entity/usershow}/TicketingAlert.java (93%) create mode 100644 app/domain/show-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepository.java rename app/domain/{user-domain => show-domain}/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java (67%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/repository/interest/InterestShowRepository.java (91%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepository.java (81%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepositoryImpl.java (84%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionRepository.java (90%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepository.java (81%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepositoryImpl.java (73%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionRepository.java (90%) create mode 100644 app/domain/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepository.java create mode 100644 app/domain/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepositoryImpl.java rename app/domain/{user-domain => show-domain}/src/main/java/org/example/repository/ticketing/TicketingAlertRepository.java (90%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/usecase/ArtistSubscriptionUseCase.java (80%) rename app/domain/show-domain/src/main/java/org/example/usecase/{artist => }/ArtistUseCase.java (99%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/usecase/GenreSubscriptionUseCase.java (85%) rename app/domain/show-domain/src/main/java/org/example/usecase/{genre => }/GenreUseCase.java (98%) rename app/domain/{user-domain/src/main/java/org/example/usecase/UserShowUseCase.java => show-domain/src/main/java/org/example/usecase/InterestShowUseCase.java} (52%) rename app/domain/show-domain/src/main/java/org/example/usecase/{show => }/ShowAdminUseCase.java (99%) rename app/domain/show-domain/src/main/java/org/example/usecase/{show => }/ShowUseCase.java (98%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/usecase/TicketingAlertUseCase.java (87%) rename app/domain/{user-domain => show-domain}/src/main/java/org/example/vo/TicketingAlertTime.java (72%) rename app/domain/{user-domain/src/testFixtures/java/org/example/fixture => show-domain/src/testFixtures/java/org/example/fixture/domain}/ArtistSubscriptionFixture.java (82%) rename app/domain/{user-domain/src/testFixtures/java/org/example/fixture => show-domain/src/testFixtures/java/org/example/fixture/domain}/GenreSubscriptionFixture.java (82%) delete mode 100644 app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepository.java delete mode 100644 app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepository.java delete mode 100644 app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepositoryImpl.java delete mode 100644 app/domain/user-domain/src/main/java/org/example/vo/TicketingType.java diff --git a/.github/workflows/showpot-dev-ci.yml b/.github/workflows/showpot-dev-ci.yml index 1bde2023..8e77580d 100644 --- a/.github/workflows/showpot-dev-ci.yml +++ b/.github/workflows/showpot-dev-ci.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - develop + - temp-develop jobs: build: diff --git a/app/api/build.gradle b/app/api/build.gradle index 090a078c..83a3cf26 100644 --- a/app/api/build.gradle +++ b/app/api/build.gradle @@ -15,6 +15,7 @@ allprojects { implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.3.0' implementation "org.springframework.boot:spring-boot-starter-web" + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-validation' } diff --git a/app/api/show-api/src/main/java/com/example/artist/controller/ArtistController.java b/app/api/show-api/src/main/java/com/example/artist/controller/ArtistController.java index 97749bc6..f0bbe599 100644 --- a/app/api/show-api/src/main/java/com/example/artist/controller/ArtistController.java +++ b/app/api/show-api/src/main/java/com/example/artist/controller/ArtistController.java @@ -12,6 +12,7 @@ import com.example.artist.controller.dto.response.ArtistFilterTotalCountApiResponse; import com.example.artist.controller.dto.response.ArtistSubscriptionApiResponse; import com.example.artist.controller.dto.response.ArtistUnsubscriptionApiResponse; +import com.example.artist.controller.dto.response.NumberOfSubscribedArtistApiResponse; import com.example.artist.service.ArtistService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -83,6 +84,18 @@ public ResponseEntity getNumberOfSubscribedArtist( + @AuthenticationPrincipal AuthenticatedUser user + ) { + return ResponseEntity.ok( + NumberOfSubscribedArtistApiResponse.from( + artistService.countSubscribedArtists(user.userId()) + ) + ); + } + @PostMapping("/subscribe") @Operation(summary = "구독하기") public ResponseEntity subscribe( diff --git a/app/api/show-api/src/main/java/com/example/artist/controller/dto/response/NumberOfSubscribedArtistApiResponse.java b/app/api/show-api/src/main/java/com/example/artist/controller/dto/response/NumberOfSubscribedArtistApiResponse.java new file mode 100644 index 00000000..5c993d35 --- /dev/null +++ b/app/api/show-api/src/main/java/com/example/artist/controller/dto/response/NumberOfSubscribedArtistApiResponse.java @@ -0,0 +1,15 @@ +package com.example.artist.controller.dto.response; + + +import com.example.artist.service.dto.response.NumberOfSubscribedArtistServiceResponse; + +public record NumberOfSubscribedArtistApiResponse( + long count +) { + + public static NumberOfSubscribedArtistApiResponse from( + NumberOfSubscribedArtistServiceResponse response + ) { + return new NumberOfSubscribedArtistApiResponse(response.count()); + } +} diff --git a/app/api/show-api/src/main/java/com/example/artist/service/ArtistAdminService.java b/app/api/show-api/src/main/java/com/example/artist/service/ArtistAdminService.java index 3d1a83a1..cde84048 100644 --- a/app/api/show-api/src/main/java/com/example/artist/service/ArtistAdminService.java +++ b/app/api/show-api/src/main/java/com/example/artist/service/ArtistAdminService.java @@ -10,7 +10,7 @@ import lombok.RequiredArgsConstructor; import org.example.dto.artist.response.ArtistDetailDomainResponse; import org.example.entity.artist.Artist; -import org.example.usecase.artist.ArtistUseCase; +import org.example.usecase.ArtistUseCase; import org.springframework.stereotype.Service; @Service diff --git a/app/api/show-api/src/main/java/com/example/artist/service/ArtistService.java b/app/api/show-api/src/main/java/com/example/artist/service/ArtistService.java index 8d59185b..3046abc8 100644 --- a/app/api/show-api/src/main/java/com/example/artist/service/ArtistService.java +++ b/app/api/show-api/src/main/java/com/example/artist/service/ArtistService.java @@ -12,6 +12,7 @@ import com.example.artist.service.dto.response.ArtistFilterTotalCountServiceResponse; import com.example.artist.service.dto.response.ArtistSubscriptionServiceResponse; import com.example.artist.service.dto.response.ArtistUnsubscriptionServiceResponse; +import com.example.artist.service.dto.response.NumberOfSubscribedArtistServiceResponse; import com.example.publish.MessagePublisher; import com.example.publish.message.ArtistServiceMessage; import com.example.publish.message.ArtistSubscriptionServiceMessage; @@ -20,12 +21,11 @@ import java.util.UUID; import lombok.RequiredArgsConstructor; import org.example.dto.response.PaginationServiceResponse; -import org.example.entity.ArtistSubscription; import org.example.entity.artist.Artist; +import org.example.entity.usershow.ArtistSubscription; import org.example.usecase.ArtistSubscriptionUseCase; -import org.example.usecase.UserShowUseCase; +import org.example.usecase.ArtistUseCase; import org.example.usecase.UserUseCase; -import org.example.usecase.artist.ArtistUseCase; import org.springframework.stereotype.Service; @Service @@ -35,7 +35,6 @@ public class ArtistService { private final ArtistUseCase artistUseCase; private final ArtistSubscriptionUseCase artistSubscriptionUseCase; - private final UserShowUseCase userShowUseCase; private final UserUseCase userUseCase; private final MessagePublisher messagePublisher; @@ -46,7 +45,7 @@ public PaginationServiceResponse searchArtis List subscribedArtistIds = request.userId() == null ? List.of() - : userShowUseCase.findArtistSubscriptionByUserId(request.userId()).stream() + : artistSubscriptionUseCase.findArtistSubscriptionByUserId(request.userId()).stream() .map(ArtistSubscription::getArtistId) .toList(); @@ -123,7 +122,6 @@ public ArtistUnsubscriptionServiceResponse unsubscribe( .map(ArtistServiceMessage::toUnsubscribe) .toList(); - var userFcmToken = userUseCase.findUserFcmTokensByUserId(request.userId()); messagePublisher.publishArtistSubscription( @@ -191,6 +189,12 @@ public PaginationServiceResponse fin return PaginationServiceResponse.of(data, response.hasNext()); } + public NumberOfSubscribedArtistServiceResponse countSubscribedArtists(UUID userId) { + return NumberOfSubscribedArtistServiceResponse.from( + artistSubscriptionUseCase.countSubscribedArtists(userId) + ); + } + private List getSubscriptionArtistIds(UUID userId) { List subscriptions = artistSubscriptionUseCase.findSubscriptionList( userId); diff --git a/app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfSubscribedArtistServiceResponse.java b/app/api/show-api/src/main/java/com/example/artist/service/dto/response/NumberOfSubscribedArtistServiceResponse.java similarity index 82% rename from app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfSubscribedArtistServiceResponse.java rename to app/api/show-api/src/main/java/com/example/artist/service/dto/response/NumberOfSubscribedArtistServiceResponse.java index 6b4d3872..ee8a0477 100644 --- a/app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfSubscribedArtistServiceResponse.java +++ b/app/api/show-api/src/main/java/com/example/artist/service/dto/response/NumberOfSubscribedArtistServiceResponse.java @@ -1,4 +1,4 @@ -package org.example.service.dto.response; +package com.example.artist.service.dto.response; public record NumberOfSubscribedArtistServiceResponse( long count diff --git a/app/api/show-api/src/main/java/com/example/genre/controller/GenreController.java b/app/api/show-api/src/main/java/com/example/genre/controller/GenreController.java index 9641f02a..60504653 100644 --- a/app/api/show-api/src/main/java/com/example/genre/controller/GenreController.java +++ b/app/api/show-api/src/main/java/com/example/genre/controller/GenreController.java @@ -10,6 +10,7 @@ import com.example.genre.controller.dto.request.GenreUnsubscriptionPaginationApiRequest; import com.example.genre.controller.dto.response.GenreSubscriptionApiResponse; import com.example.genre.controller.dto.response.GenreUnsubscriptionApiResponse; +import com.example.genre.controller.dto.response.NumberOfSubscribedGenreApiResponse; import com.example.genre.service.GenreService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -92,6 +93,18 @@ public ResponseEntity ); } + @GetMapping("/subscriptions/count") + @Operation(summary = "구독한 장르 수") + public ResponseEntity getNumberOfSubscribedGenre( + @AuthenticationPrincipal AuthenticatedUser user + ) { + return ResponseEntity.ok( + NumberOfSubscribedGenreApiResponse.from( + genreService.countSubscribedGenres(user.userId()) + ) + ); + } + @PostMapping("/subscribe") @Operation(summary = "구독하기") public ResponseEntity subscribe( diff --git a/app/api/show-api/src/main/java/com/example/genre/controller/dto/response/NumberOfSubscribedGenreApiResponse.java b/app/api/show-api/src/main/java/com/example/genre/controller/dto/response/NumberOfSubscribedGenreApiResponse.java new file mode 100644 index 00000000..448ed099 --- /dev/null +++ b/app/api/show-api/src/main/java/com/example/genre/controller/dto/response/NumberOfSubscribedGenreApiResponse.java @@ -0,0 +1,15 @@ +package com.example.genre.controller.dto.response; + + +import com.example.genre.service.dto.response.NumberOfSubscribedGenreServiceResponse; + +public record NumberOfSubscribedGenreApiResponse( + long count +) { + + public static NumberOfSubscribedGenreApiResponse from( + NumberOfSubscribedGenreServiceResponse response + ) { + return new NumberOfSubscribedGenreApiResponse(response.count()); + } +} diff --git a/app/api/show-api/src/main/java/com/example/genre/service/GenreAdminService.java b/app/api/show-api/src/main/java/com/example/genre/service/GenreAdminService.java index 8a5a50e3..efd0affe 100644 --- a/app/api/show-api/src/main/java/com/example/genre/service/GenreAdminService.java +++ b/app/api/show-api/src/main/java/com/example/genre/service/GenreAdminService.java @@ -7,7 +7,7 @@ import java.util.UUID; import lombok.RequiredArgsConstructor; import org.example.entity.genre.Genre; -import org.example.usecase.genre.GenreUseCase; +import org.example.usecase.GenreUseCase; import org.springframework.stereotype.Service; @Service diff --git a/app/api/show-api/src/main/java/com/example/genre/service/GenreService.java b/app/api/show-api/src/main/java/com/example/genre/service/GenreService.java index 2819975b..8b8eadee 100644 --- a/app/api/show-api/src/main/java/com/example/genre/service/GenreService.java +++ b/app/api/show-api/src/main/java/com/example/genre/service/GenreService.java @@ -10,6 +10,7 @@ import com.example.genre.service.dto.request.GenreUnsubscriptionServiceRequest; import com.example.genre.service.dto.response.GenreSubscriptionServiceResponse; import com.example.genre.service.dto.response.GenreUnsubscriptionServiceResponse; +import com.example.genre.service.dto.response.NumberOfSubscribedGenreServiceResponse; import com.example.publish.MessagePublisher; import com.example.publish.message.GenreServiceMessage; import com.example.publish.message.GenreSubscriptionServiceMessage; @@ -18,11 +19,11 @@ import lombok.RequiredArgsConstructor; import org.example.dto.genre.response.GenrePaginationDomainResponse; import org.example.dto.response.PaginationServiceResponse; -import org.example.entity.GenreSubscription; import org.example.entity.genre.Genre; +import org.example.entity.usershow.GenreSubscription; import org.example.usecase.GenreSubscriptionUseCase; +import org.example.usecase.GenreUseCase; import org.example.usecase.UserUseCase; -import org.example.usecase.genre.GenreUseCase; import org.springframework.stereotype.Service; @Service @@ -100,7 +101,9 @@ public GenreUnsubscriptionServiceResponse unsubscribe( .build(); } - public PaginationServiceResponse findGenres(GenrePaginationServiceRequest request) { + public PaginationServiceResponse findGenres( + GenrePaginationServiceRequest request + ) { List subscriptionGenreIds = request.userId() == null ? List.of() : getSubscriptionGenreIds(request.userId()); @@ -146,6 +149,12 @@ public PaginationServiceResponse find return PaginationServiceResponse.of(data, response.hasNext()); } + public NumberOfSubscribedGenreServiceResponse countSubscribedGenres(UUID uuid) { + return NumberOfSubscribedGenreServiceResponse.from( + genreSubscriptionUseCase.countSubscribedGenres(uuid) + ); + } + private List getSubscriptionGenreIds(UUID userId) { List subscriptions = genreSubscriptionUseCase.findSubscriptions(userId); diff --git a/app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfSubscribedGenreServiceResponse.java b/app/api/show-api/src/main/java/com/example/genre/service/dto/response/NumberOfSubscribedGenreServiceResponse.java similarity index 82% rename from app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfSubscribedGenreServiceResponse.java rename to app/api/show-api/src/main/java/com/example/genre/service/dto/response/NumberOfSubscribedGenreServiceResponse.java index dac0cd56..8d36f0f5 100644 --- a/app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfSubscribedGenreServiceResponse.java +++ b/app/api/show-api/src/main/java/com/example/genre/service/dto/response/NumberOfSubscribedGenreServiceResponse.java @@ -1,4 +1,4 @@ -package org.example.service.dto.response; +package com.example.genre.service.dto.response; public record NumberOfSubscribedGenreServiceResponse( long count diff --git a/app/api/show-api/src/main/java/com/example/publish/message/ArtistServiceMessage.java b/app/api/show-api/src/main/java/com/example/publish/message/ArtistServiceMessage.java index 03ef2295..8b8c45cf 100644 --- a/app/api/show-api/src/main/java/com/example/publish/message/ArtistServiceMessage.java +++ b/app/api/show-api/src/main/java/com/example/publish/message/ArtistServiceMessage.java @@ -2,8 +2,8 @@ import java.util.UUID; import lombok.Builder; -import org.example.entity.ArtistSubscription; import org.example.entity.artist.Artist; +import org.example.entity.usershow.ArtistSubscription; @Builder public record ArtistServiceMessage( diff --git a/app/api/show-api/src/main/java/com/example/publish/message/GenreServiceMessage.java b/app/api/show-api/src/main/java/com/example/publish/message/GenreServiceMessage.java index fd48ab03..8649e4b9 100644 --- a/app/api/show-api/src/main/java/com/example/publish/message/GenreServiceMessage.java +++ b/app/api/show-api/src/main/java/com/example/publish/message/GenreServiceMessage.java @@ -2,8 +2,8 @@ import java.util.UUID; import lombok.Builder; -import org.example.entity.GenreSubscription; import org.example.entity.genre.Genre; +import org.example.entity.usershow.GenreSubscription; @Builder public record GenreServiceMessage( diff --git a/app/api/show-api/src/main/java/com/example/publish/message/TicketingAlertsToReserveServiceMessage.java b/app/api/show-api/src/main/java/com/example/publish/message/TicketingAlertsToReserveServiceMessage.java index f2b30107..17f131d6 100644 --- a/app/api/show-api/src/main/java/com/example/publish/message/TicketingAlertsToReserveServiceMessage.java +++ b/app/api/show-api/src/main/java/com/example/publish/message/TicketingAlertsToReserveServiceMessage.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.UUID; import lombok.Builder; -import org.example.dto.response.TicketingAlertsDomainResponse; +import org.example.dto.usershow.response.TicketingAlertsDomainResponse; @Builder public record TicketingAlertsToReserveServiceMessage( @@ -14,11 +14,12 @@ public record TicketingAlertsToReserveServiceMessage( List deleteAts ) { - public static TicketingAlertsToReserveServiceMessage from( - TicketingAlertsDomainResponse responses + public static TicketingAlertsToReserveServiceMessage of( + TicketingAlertsDomainResponse responses, + String userFcmToken ) { return TicketingAlertsToReserveServiceMessage.builder() - .userFcmToken(responses.userFcmToken()) + .userFcmToken(userFcmToken) .name(responses.name()) .showId(responses.showId()) .addAts(responses.addAts().stream().map(TicketingTimeServiceMessage::from).toList()) diff --git a/app/api/show-api/src/main/java/com/example/publish/message/TicketingTimeServiceMessage.java b/app/api/show-api/src/main/java/com/example/publish/message/TicketingTimeServiceMessage.java index 9abdca9d..e60fc331 100644 --- a/app/api/show-api/src/main/java/com/example/publish/message/TicketingTimeServiceMessage.java +++ b/app/api/show-api/src/main/java/com/example/publish/message/TicketingTimeServiceMessage.java @@ -3,7 +3,7 @@ import com.example.show.controller.vo.TicketingAlertTimeApiType; import java.time.LocalDateTime; import lombok.Builder; -import org.example.dto.response.TicketingTimeDomainResponse; +import org.example.dto.usershow.response.TicketingTimeDomainResponse; @Builder public record TicketingTimeServiceMessage( diff --git a/app/api/show-api/src/main/java/com/example/show/controller/ShowController.java b/app/api/show-api/src/main/java/com/example/show/controller/ShowController.java index 3b6d1594..13d71142 100644 --- a/app/api/show-api/src/main/java/com/example/show/controller/ShowController.java +++ b/app/api/show-api/src/main/java/com/example/show/controller/ShowController.java @@ -1,28 +1,14 @@ package com.example.show.controller; -import com.example.show.controller.dto.param.ShowAlertPaginationApiParam; import com.example.show.controller.dto.param.ShowSearchPaginationApiParam; -import com.example.show.controller.dto.request.ShowAlertPaginationApiRequest; -import com.example.show.controller.dto.request.ShowInterestPaginationApiRequest; import com.example.show.controller.dto.request.ShowPaginationApiRequest; import com.example.show.controller.dto.request.ShowSearchPaginationApiRequest; -import com.example.show.controller.dto.request.TicketingAlertReservationApiRequest; -import com.example.show.controller.dto.response.InterestShowPaginationApiResponse; import com.example.show.controller.dto.response.ShowDetailApiResponse; -import com.example.show.controller.dto.response.ShowInterestApiResponse; import com.example.show.controller.dto.response.ShowPaginationApiParam; -import com.example.show.controller.dto.response.TerminatedTicketingShowCountApiResponse; -import com.example.show.controller.dto.response.TicketingAlertReservationApiResponse; -import com.example.show.controller.vo.TicketingApiType; import com.example.show.service.ShowService; -import com.example.show.service.dto.param.ShowAlertPaginationServiceParam; -import com.example.show.service.dto.request.ShowInterestServiceRequest; import com.example.show.service.dto.response.ShowPaginationServiceResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import java.time.LocalDateTime; -import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.example.dto.response.PaginationApiResponse; @@ -34,11 +20,8 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController @@ -71,46 +54,6 @@ public ResponseEntity> getShows( } - @PostMapping("/{showId}/interests") - @Operation(summary = "공연 관심 등록 / 취소") - public ResponseEntity interest( - @PathVariable("showId") UUID showId, - @AuthenticationPrincipal AuthenticatedUser user - ) { - return ResponseEntity.ok( - ShowInterestApiResponse.from( - showService.interest( - ShowInterestServiceRequest.builder() - .showId(showId) - .userId(user.userId()) - .build() - ) - ) - ); - } - - @GetMapping("/interests") - @Operation(summary = "공연 관심 목록 조회") - public ResponseEntity> getInterests( - @ParameterObject ShowInterestPaginationApiRequest request, - @AuthenticationPrincipal AuthenticatedUser user - ) { - var serviceResponse = showService.findInterestShows( - request.toServiceRequest(user.userId()) - ); - - List response = serviceResponse.data().stream() - .map(InterestShowPaginationApiResponse::from) - .toList(); - - return ResponseEntity.ok( - PaginationApiResponse.builder() - .data(response) - .hasNext(serviceResponse.hasNext()) - .build() - ); - } - @GetMapping("/{showId}") @Operation(summary = "공연 상세 조회") public ResponseEntity getShow( @@ -125,60 +68,6 @@ public ResponseEntity getShow( ); } - @GetMapping("/{showId}/alert/reservations") - @Operation(summary = "공연 티켓팅 알림 예약 조회") - public ResponseEntity getAlertsReservations( - @AuthenticationPrincipal AuthenticatedUser user, - @PathVariable("showId") UUID showId, - @RequestParam("ticketingApiType") TicketingApiType type - ) { - var now = LocalDateTime.now(); - return ResponseEntity.ok( - TicketingAlertReservationApiResponse.from( - showService.findAlertsReservations(user.userId(), showId, type, now) - ) - ); - } - - @PostMapping("/{showId}/alert") - @Operation( - summary = "공연 티켓팅 알림 등록 / 취소", - description = "요청한 알람 시간으로 기존 내용을 덮어쓴다." - ) - public ResponseEntity alert( - @AuthenticationPrincipal AuthenticatedUser user, - @PathVariable("showId") UUID showId, - @RequestParam("ticketingApiType") TicketingApiType type, - @Valid @RequestBody TicketingAlertReservationApiRequest ticketingAlertReservationRequest - ) { - showService.alertReservation( - ticketingAlertReservationRequest.toServiceRequest(user.userId(), showId, type) - ); - - return ResponseEntity.noContent().build(); - } - - @GetMapping("/alerts") - @Operation(summary = "공연 알림 목록 조회") - public ResponseEntity> getAlerts( - @AuthenticationPrincipal AuthenticatedUser user, - @ParameterObject ShowAlertPaginationApiRequest request - ) { - PaginationServiceResponse alertShows = showService.findAlertShows( - request.toServiceRequest(user.userId())); - - var showAlertPaginationApiParams = alertShows.data().stream() - .map(ShowAlertPaginationApiParam::from) - .toList(); - - return ResponseEntity.ok( - PaginationApiResponse.builder() - .data(showAlertPaginationApiParams) - .hasNext(alertShows.hasNext()) - .build() - ); - } - @GetMapping("/search") @Operation(summary = "검색하기") public ResponseEntity> search( @@ -197,16 +86,4 @@ public ResponseEntity> searc .build() ); } - - @GetMapping("/terminated/ticketing/count") - @Operation(summary = "티켓팅 알림 설정 후 공연이 종료된 개수") - public ResponseEntity getNumberOfTerminatedTicketingShowCount( - @AuthenticationPrincipal AuthenticatedUser user - ) { - return ResponseEntity.ok( - TerminatedTicketingShowCountApiResponse.from( - showService.countTerminatedTicketingShow(user.userId()) - ) - ); - } } diff --git a/app/api/show-api/src/main/java/com/example/show/controller/UserShowController.java b/app/api/show-api/src/main/java/com/example/show/controller/UserShowController.java new file mode 100644 index 00000000..a5c98dbc --- /dev/null +++ b/app/api/show-api/src/main/java/com/example/show/controller/UserShowController.java @@ -0,0 +1,176 @@ +package com.example.show.controller; + +import com.example.show.controller.dto.param.ShowAlertPaginationApiParam; +import com.example.show.controller.dto.request.ShowAlertPaginationApiRequest; +import com.example.show.controller.dto.request.ShowInterestPaginationApiRequest; +import com.example.show.controller.dto.request.TicketingAlertReservationApiRequest; +import com.example.show.controller.dto.response.InterestShowPaginationApiResponse; +import com.example.show.controller.dto.response.ShowInterestApiResponse; +import com.example.show.controller.dto.response.TerminatedTicketingShowCountApiResponse; +import com.example.show.controller.dto.response.TicketingAlertReservationApiResponse; +import com.example.show.controller.dto.usershow.response.NumberOfInterestShowApiResponse; +import com.example.show.controller.dto.usershow.response.NumberOfTicketingAlertApiResponse; +import com.example.show.controller.vo.TicketingApiType; +import com.example.show.service.UserShowService; +import com.example.show.service.dto.param.ShowAlertPaginationServiceParam; +import com.example.show.service.dto.request.ShowInterestServiceRequest; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import java.time.LocalDateTime; +import java.util.List; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.example.dto.response.PaginationApiResponse; +import org.example.dto.response.PaginationServiceResponse; +import org.example.security.dto.AuthenticatedUser; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/shows") +@Tag(name = "공연") +public class UserShowController { + + private final UserShowService userShowService; + + @PostMapping("/{showId}/interests") + @Operation(summary = "공연 관심 등록 / 취소") + public ResponseEntity interest( + @PathVariable("showId") UUID showId, + @AuthenticationPrincipal AuthenticatedUser user + ) { + return ResponseEntity.ok( + ShowInterestApiResponse.from( + userShowService.interest( + ShowInterestServiceRequest.builder() + .showId(showId) + .userId(user.userId()) + .build() + ) + ) + ); + } + + @GetMapping("/interests") + @Operation(summary = "공연 관심 목록 조회") + public ResponseEntity> getInterests( + @ParameterObject ShowInterestPaginationApiRequest request, + @AuthenticationPrincipal AuthenticatedUser user + ) { + var serviceResponse = userShowService.findInterestShows( + request.toServiceRequest(user.userId()) + ); + + List response = serviceResponse.data().stream() + .map(InterestShowPaginationApiResponse::from) + .toList(); + + return ResponseEntity.ok( + PaginationApiResponse.builder() + .data(response) + .hasNext(serviceResponse.hasNext()) + .build() + ); + } + + @GetMapping("/interests/count") + @Operation(summary = "관심 공연 개수") + public ResponseEntity getNumberOfInterestShow( + @AuthenticationPrincipal AuthenticatedUser user + ) { + return ResponseEntity.ok( + NumberOfInterestShowApiResponse.from( + userShowService.countInterestShows(user.userId()) + ) + ); + } + + @PostMapping("/{showId}/alert") + @Operation( + summary = "공연 티켓팅 알림 등록 / 취소", + description = "요청한 알람 시간으로 기존 내용을 덮어쓴다." + ) + public ResponseEntity alert( + @AuthenticationPrincipal AuthenticatedUser user, + @PathVariable("showId") UUID showId, + @RequestParam("ticketingApiType") TicketingApiType type, + @Valid @RequestBody TicketingAlertReservationApiRequest ticketingAlertReservationRequest + ) { + userShowService.alertReservation( + ticketingAlertReservationRequest.toServiceRequest(user.userId(), showId, type) + ); + + return ResponseEntity.noContent().build(); + } + + @GetMapping("/alerts") + @Operation(summary = "공연 알림 목록 조회") + public ResponseEntity> getAlerts( + @AuthenticationPrincipal AuthenticatedUser user, + @ParameterObject ShowAlertPaginationApiRequest request + ) { + PaginationServiceResponse alertShows = userShowService.findAlertShows( + request.toServiceRequest(user.userId())); + + var showAlertPaginationApiParams = alertShows.data().stream() + .map(ShowAlertPaginationApiParam::from) + .toList(); + + return ResponseEntity.ok( + PaginationApiResponse.builder() + .data(showAlertPaginationApiParams) + .hasNext(alertShows.hasNext()) + .build() + ); + } + + @GetMapping("/{showId}/alert/reservations") + @Operation(summary = "공연 티켓팅 알림 예약 조회") + public ResponseEntity getAlertsReservations( + @AuthenticationPrincipal AuthenticatedUser user, + @PathVariable("showId") UUID showId, + @RequestParam("ticketingApiType") TicketingApiType type + ) { + var now = LocalDateTime.now(); + return ResponseEntity.ok( + TicketingAlertReservationApiResponse.from( + userShowService.findAlertsReservations(user.userId(), showId, type, now) + ) + ); + } + + @GetMapping("/alerts/count") + @Operation(summary = "알림 설정한 공연 개수") + public ResponseEntity getNumberOfAlertShow( + @AuthenticationPrincipal AuthenticatedUser user + ) { + LocalDateTime now = LocalDateTime.now(); + return ResponseEntity.ok( + NumberOfTicketingAlertApiResponse.from( + userShowService.countAlertShows(user.userId(), now) + ) + ); + } + + @GetMapping("/terminated/ticketing/count") + @Operation(summary = "티켓팅 알림 설정 후 공연이 종료된 개수") + public ResponseEntity getNumberOfTerminatedTicketingShowCount( + @AuthenticationPrincipal AuthenticatedUser user + ) { + return ResponseEntity.ok( + TerminatedTicketingShowCountApiResponse.from( + userShowService.countTerminatedTicketingShow(user.userId()) + ) + ); + } +} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/usershow/response/NumberOfInterestShowApiResponse.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/usershow/response/NumberOfInterestShowApiResponse.java new file mode 100644 index 00000000..4e04d526 --- /dev/null +++ b/app/api/show-api/src/main/java/com/example/show/controller/dto/usershow/response/NumberOfInterestShowApiResponse.java @@ -0,0 +1,15 @@ +package com.example.show.controller.dto.usershow.response; + + +import com.example.show.service.dto.usershow.response.NumberOfInterestShowServiceResponse; + +public record NumberOfInterestShowApiResponse( + long count +) { + + public static NumberOfInterestShowApiResponse from( + NumberOfInterestShowServiceResponse response + ) { + return new NumberOfInterestShowApiResponse(response.count()); + } +} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/usershow/response/NumberOfTicketingAlertApiResponse.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/usershow/response/NumberOfTicketingAlertApiResponse.java new file mode 100644 index 00000000..11732343 --- /dev/null +++ b/app/api/show-api/src/main/java/com/example/show/controller/dto/usershow/response/NumberOfTicketingAlertApiResponse.java @@ -0,0 +1,15 @@ +package com.example.show.controller.dto.usershow.response; + + +import com.example.show.service.dto.usershow.response.NumberOfTicketingAlertServiceResponse; + +public record NumberOfTicketingAlertApiResponse( + long count +) { + + public static NumberOfTicketingAlertApiResponse from( + NumberOfTicketingAlertServiceResponse response + ) { + return new NumberOfTicketingAlertApiResponse(response.count()); + } +} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/vo/TicketingAlertTimeApiType.java b/app/api/show-api/src/main/java/com/example/show/controller/vo/TicketingAlertTimeApiType.java index 191d0123..dfea482b 100644 --- a/app/api/show-api/src/main/java/com/example/show/controller/vo/TicketingAlertTimeApiType.java +++ b/app/api/show-api/src/main/java/com/example/show/controller/vo/TicketingAlertTimeApiType.java @@ -46,11 +46,11 @@ public static List availableReserveTimeToDomainType( LocalDateTime ticketingAt, List alertTimes ) { - long hoursDifference = Duration.between(LocalDateTime.now(), ticketingAt).toHours(); + long minutesDifference = Duration.between(LocalDateTime.now(), ticketingAt).toMinutes(); return alertTimes.stream() .filter(alertTime -> switch (alertTime) { - case BEFORE_A_DAY, BEFORE_SIX_HOURS, BEFORE_A_HOUR -> hoursDifference >= alertTime.minutes; + case BEFORE_A_DAY, BEFORE_SIX_HOURS, BEFORE_A_HOUR -> minutesDifference >= alertTime.minutes; }) .map(TicketingAlertTimeApiType::toDomainType) .toList(); diff --git a/app/api/show-api/src/main/java/com/example/show/service/ShowAdminService.java b/app/api/show-api/src/main/java/com/example/show/service/ShowAdminService.java index 11ae5c6e..65eb0137 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/ShowAdminService.java +++ b/app/api/show-api/src/main/java/com/example/show/service/ShowAdminService.java @@ -11,9 +11,9 @@ import java.util.UUID; import lombok.RequiredArgsConstructor; import org.example.dto.show.response.ShowInfoDomainResponse; -import org.example.usecase.artist.ArtistUseCase; -import org.example.usecase.genre.GenreUseCase; -import org.example.usecase.show.ShowAdminUseCase; +import org.example.usecase.ArtistUseCase; +import org.example.usecase.GenreUseCase; +import org.example.usecase.ShowAdminUseCase; import org.springframework.stereotype.Service; @Service 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 6307e0a5..92131482 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 @@ -1,41 +1,19 @@ package com.example.show.service; import com.example.component.ViewCountComponent; -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; -import com.example.show.service.dto.request.ShowAlertPaginationServiceRequest; -import com.example.show.service.dto.request.ShowInterestServiceRequest; import com.example.show.service.dto.request.ShowPaginationServiceRequest; import com.example.show.service.dto.request.ShowSearchPaginationServiceRequest; -import com.example.show.service.dto.request.TicketingAlertReservationServiceRequest; -import com.example.show.service.dto.response.InterestShowPaginationServiceResponse; import com.example.show.service.dto.response.ShowDetailServiceResponse; -import com.example.show.service.dto.response.ShowInterestServiceResponse; import com.example.show.service.dto.response.ShowPaginationServiceResponse; -import com.example.show.service.dto.response.TerminatedTicketingShowCountServiceResponse; -import com.example.show.service.dto.response.TicketingAlertReservationServiceResponse; import java.time.LocalDateTime; import java.util.List; -import java.util.Map; import java.util.UUID; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.example.dto.response.PaginationServiceResponse; -import org.example.dto.show.response.ShowAlertPaginationDomainResponse; import org.example.dto.show.response.ShowDetailDomainResponse; -import org.example.entity.InterestShow; -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; +import org.example.usecase.InterestShowUseCase; +import org.example.usecase.ShowUseCase; import org.springframework.stereotype.Service; @Service @@ -43,16 +21,14 @@ public class ShowService { private final ShowUseCase showUseCase; - private final TicketingAlertUseCase ticketingAlertUseCase; - private final UserShowUseCase userShowUseCase; - private final MessagePublisher messagePublisher; + private final InterestShowUseCase interestShowUseCase; private final ViewCountComponent viewCountComponent; public ShowDetailServiceResponse getShow(UUID userId, UUID showId, String viewIdentifier) { ShowDetailDomainResponse showDetail = showUseCase.findShowDetail(showId); boolean isInterested = - userId != null && userShowUseCase.findInterestShow(showId, userId).isPresent(); + userId != null && interestShowUseCase.findInterestShow(showId, userId).isPresent(); if (viewCountComponent.validateViewCount(showId, viewIdentifier)) { showUseCase.view(showId); @@ -90,108 +66,4 @@ public PaginationServiceResponse findShows( response.hasNext() ); } - - public PaginationServiceResponse findInterestShows( - InterestShowPaginationServiceRequest request - ) { - var interestShows = userShowUseCase.findInterestShows(request.toDomainRequest()); - List showIds = interestShows.data().stream().map(InterestShow::getShowId).toList(); - Map showById = showUseCase.findShowsInIds(showIds).stream() - .collect(Collectors.toMap(Show::getId, s -> s)); - - return PaginationServiceResponse.of( - interestShows.data().stream() - .map(interestShow -> InterestShowPaginationServiceResponse.from( - showById.get(interestShow.getShowId()), - interestShow - )) - .toList(), - interestShows.hasNext() - ); - } - - public ShowInterestServiceResponse interest(ShowInterestServiceRequest request) { - Show show = showUseCase.findShowOrThrowNoSuchElementException(request.showId()); - - return ShowInterestServiceResponse.from( - userShowUseCase.interest(request.toDomainRequest(show.getId())) - ); - } - - public TicketingAlertReservationServiceResponse findAlertsReservations( - UUID userId, - UUID showId, - TicketingApiType type, - LocalDateTime now - ) { - ShowTicketingTime ticketingTime = showUseCase.findTicketingAlertReservation(showId, type.toDomainType()); - List ticketingAlerts = ticketingAlertUseCase.findTicketingAlerts(userId, showId); - - return TicketingAlertReservationServiceResponse.as( - ticketingTime.getTicketingAt(), - ticketingAlerts, - now - ); - } - - public void alertReservation( - TicketingAlertReservationServiceRequest ticketingAlertReservationRequest - ) { - ShowTicketingTime showTicketingTime = showUseCase.findTicketingTimeWithShow( - ticketingAlertReservationRequest.showId(), - ticketingAlertReservationRequest.type().toDomainType() - ); - - if (showTicketingTime.getTicketingAt().isBefore(LocalDateTime.now())) { - throw new BusinessException(ShowError.TICKETING_ALERT_RESERVED_ERROR); - } - - var domainResponse = ticketingAlertUseCase.alertReservation( - ticketingAlertReservationRequest.toDomainRequest( - showTicketingTime.getShow().getTitle(), - showTicketingTime.getTicketingAt() - ) - ); - messagePublisher.publishTicketingReservation( - "ticketingAlert", - TicketingAlertsToReserveServiceMessage.from(domainResponse) - ); - } - - public PaginationServiceResponse findAlertShows( - ShowAlertPaginationServiceRequest request - ) { - List ticketingAlerts = ticketingAlertUseCase.findTicketingAlertsByUserId( - request.userId()); - List showIdsToAlert = ticketingAlerts.stream() - .map(TicketingAlert::getShowId) - .distinct() - .toList(); - - ShowAlertPaginationDomainResponse alertShows = showUseCase.findAlertShows( - request.toDomainRequest(showIdsToAlert, LocalDateTime.now())); - - return PaginationServiceResponse.of(alertShows.data().stream() - .map(ShowAlertPaginationServiceParam::from) - .toList(), - alertShows.hasNext() - ); - } - - public TerminatedTicketingShowCountServiceResponse countTerminatedTicketingShow(UUID userId) { - List ticketingAlerts = ticketingAlertUseCase.findTicketingAlertsByUserId( - userId); - List showIdsToAlert = ticketingAlerts.stream() - .map(TicketingAlert::getShowId) - .distinct() - .toList(); - - if (showIdsToAlert.isEmpty()) { - return TerminatedTicketingShowCountServiceResponse.noCount(); - } - - return TerminatedTicketingShowCountServiceResponse.from( - showUseCase.findTerminatedTicketingShowsCount(showIdsToAlert, LocalDateTime.now()) - ); - } } 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 new file mode 100644 index 00000000..b5bf602b --- /dev/null +++ b/app/api/show-api/src/main/java/com/example/show/service/UserShowService.java @@ -0,0 +1,165 @@ +package com.example.show.service; + +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.request.InterestShowPaginationServiceRequest; +import com.example.show.service.dto.request.ShowAlertPaginationServiceRequest; +import com.example.show.service.dto.request.ShowInterestServiceRequest; +import com.example.show.service.dto.request.TicketingAlertReservationServiceRequest; +import com.example.show.service.dto.response.InterestShowPaginationServiceResponse; +import com.example.show.service.dto.response.ShowInterestServiceResponse; +import com.example.show.service.dto.response.TerminatedTicketingShowCountServiceResponse; +import com.example.show.service.dto.response.TicketingAlertReservationServiceResponse; +import com.example.show.service.dto.usershow.response.NumberOfInterestShowServiceResponse; +import com.example.show.service.dto.usershow.response.NumberOfTicketingAlertServiceResponse; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; +import org.example.dto.response.PaginationServiceResponse; +import org.example.dto.show.response.ShowAlertPaginationDomainResponse; +import org.example.entity.show.Show; +import org.example.entity.show.ShowTicketingTime; +import org.example.entity.usershow.InterestShow; +import org.example.entity.usershow.TicketingAlert; +import org.example.exception.BusinessException; +import org.example.usecase.InterestShowUseCase; +import org.example.usecase.ShowUseCase; +import org.example.usecase.TicketingAlertUseCase; +import org.example.usecase.UserUseCase; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class UserShowService { + + private final ShowUseCase showUseCase; + private final UserUseCase userUseCase; + private final TicketingAlertUseCase ticketingAlertUseCase; + private final InterestShowUseCase interestShowUseCase; + private final MessagePublisher messagePublisher; + + public ShowInterestServiceResponse interest(ShowInterestServiceRequest request) { + Show show = showUseCase.findShowOrThrowNoSuchElementException(request.showId()); + + return ShowInterestServiceResponse.from( + interestShowUseCase.interest(request.toDomainRequest(show.getId())) + ); + } + + public PaginationServiceResponse findInterestShows( + InterestShowPaginationServiceRequest request + ) { + var interestShows = interestShowUseCase.findInterestShows(request.toDomainRequest()); + List showIds = interestShows.data().stream().map(InterestShow::getShowId).toList(); + Map showById = showUseCase.findShowsInIds(showIds).stream() + .collect(Collectors.toMap(Show::getId, s -> s)); + + return PaginationServiceResponse.of( + interestShows.data().stream() + .map(interestShow -> InterestShowPaginationServiceResponse.from( + showById.get(interestShow.getShowId()), + interestShow + )) + .toList(), + interestShows.hasNext() + ); + } + + public NumberOfInterestShowServiceResponse countInterestShows(UUID uuid) { + return NumberOfInterestShowServiceResponse.from( + interestShowUseCase.countInterestShows(uuid) + ); + } + + public void alertReservation( + TicketingAlertReservationServiceRequest request + ) { + ShowTicketingTime showTicketingTime = showUseCase.findTicketingTimeWithShow( + request.showId(), + request.type().toDomainType() + ); + + if (showTicketingTime.getTicketingAt().isBefore(LocalDateTime.now())) { + throw new BusinessException(ShowError.TICKETING_ALERT_RESERVED_ERROR); + } + + var domainResponse = ticketingAlertUseCase.alertReservation( + request.toDomainRequest( + showTicketingTime.getShow().getTitle(), + showTicketingTime.getTicketingAt() + ) + ); + + String userFcmToken = userUseCase.findUserFcmTokensByUserId(request.userId()); + + messagePublisher.publishTicketingReservation( + "ticketingAlert", + TicketingAlertsToReserveServiceMessage.of(domainResponse, userFcmToken) + ); + } + + public PaginationServiceResponse findAlertShows( + ShowAlertPaginationServiceRequest request + ) { + List ticketingAlerts = ticketingAlertUseCase.findTicketingAlertsByUserId( + request.userId()); + List showIdsToAlert = ticketingAlerts.stream() + .map(TicketingAlert::getShowId) + .distinct() + .toList(); + + ShowAlertPaginationDomainResponse alertShows = showUseCase.findAlertShows( + request.toDomainRequest(showIdsToAlert, LocalDateTime.now())); + + return PaginationServiceResponse.of(alertShows.data().stream() + .map(ShowAlertPaginationServiceParam::from) + .toList(), + alertShows.hasNext() + ); + } + + public TicketingAlertReservationServiceResponse findAlertsReservations( + UUID userId, + UUID showId, + TicketingApiType type, + LocalDateTime now + ) { + ShowTicketingTime ticketingTime = showUseCase.findTicketingAlertReservation(showId, type.toDomainType()); + List ticketingAlerts = ticketingAlertUseCase.findTicketingAlerts(userId, showId); + + return TicketingAlertReservationServiceResponse.as( + ticketingTime.getTicketingAt(), + ticketingAlerts, + now + ); + } + + public NumberOfTicketingAlertServiceResponse countAlertShows(UUID userId, LocalDateTime now) { + long numberOfTicketingAlert = ticketingAlertUseCase.countAlertShows(userId, now); + + return NumberOfTicketingAlertServiceResponse.from(numberOfTicketingAlert); + } + + public TerminatedTicketingShowCountServiceResponse countTerminatedTicketingShow(UUID userId) { + List ticketingAlerts = ticketingAlertUseCase.findTicketingAlertsByUserId( + userId); + List showIdsToAlert = ticketingAlerts.stream() + .map(TicketingAlert::getShowId) + .distinct() + .toList(); + + if (showIdsToAlert.isEmpty()) { + return TerminatedTicketingShowCountServiceResponse.noCount(); + } + + return TerminatedTicketingShowCountServiceResponse.from( + showUseCase.findTerminatedTicketingShowsCount(showIdsToAlert, LocalDateTime.now()) + ); + } +} diff --git a/app/api/show-api/src/main/java/com/example/show/service/dto/request/InterestShowPaginationServiceRequest.java b/app/api/show-api/src/main/java/com/example/show/service/dto/request/InterestShowPaginationServiceRequest.java index 0102c697..12b799e0 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/dto/request/InterestShowPaginationServiceRequest.java +++ b/app/api/show-api/src/main/java/com/example/show/service/dto/request/InterestShowPaginationServiceRequest.java @@ -3,7 +3,7 @@ import java.time.LocalDateTime; import java.util.UUID; import lombok.Builder; -import org.example.dto.request.InterestShowPaginationDomainRequest; +import org.example.dto.usershow.request.InterestShowPaginationDomainRequest; @Builder public record InterestShowPaginationServiceRequest( 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 8309ef8e..9df1393f 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 @@ -2,7 +2,7 @@ import java.util.UUID; import lombok.Builder; -import org.example.dto.request.InterestShowDomainRequest; +import org.example.dto.usershow.request.InterestShowDomainRequest; @Builder public record ShowInterestServiceRequest( diff --git a/app/api/show-api/src/main/java/com/example/show/service/dto/request/TicketingAlertReservationServiceRequest.java b/app/api/show-api/src/main/java/com/example/show/service/dto/request/TicketingAlertReservationServiceRequest.java index ff494b52..5c98b429 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/dto/request/TicketingAlertReservationServiceRequest.java +++ b/app/api/show-api/src/main/java/com/example/show/service/dto/request/TicketingAlertReservationServiceRequest.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.UUID; import lombok.Builder; -import org.example.dto.request.TicketingAlertReservationDomainRequest; +import org.example.dto.usershow.request.TicketingAlertReservationDomainRequest; @Builder public record TicketingAlertReservationServiceRequest( 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 955ed580..c39057ad 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 @@ -4,8 +4,8 @@ import java.time.LocalDateTime; import java.util.UUID; import lombok.Builder; -import org.example.entity.InterestShow; import org.example.entity.show.Show; +import org.example.entity.usershow.InterestShow; @Builder public record InterestShowPaginationServiceResponse( diff --git a/app/api/show-api/src/main/java/com/example/show/service/dto/response/ShowInterestServiceResponse.java b/app/api/show-api/src/main/java/com/example/show/service/dto/response/ShowInterestServiceResponse.java index f5c93eff..a4558c14 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/dto/response/ShowInterestServiceResponse.java +++ b/app/api/show-api/src/main/java/com/example/show/service/dto/response/ShowInterestServiceResponse.java @@ -1,6 +1,6 @@ package com.example.show.service.dto.response; -import org.example.entity.InterestShow; +import org.example.entity.usershow.InterestShow; public record ShowInterestServiceResponse( boolean hasInterest diff --git a/app/api/show-api/src/main/java/com/example/show/service/dto/response/TicketingAlertReservationServiceResponse.java b/app/api/show-api/src/main/java/com/example/show/service/dto/response/TicketingAlertReservationServiceResponse.java index 8b9c293a..832c9ce8 100644 --- a/app/api/show-api/src/main/java/com/example/show/service/dto/response/TicketingAlertReservationServiceResponse.java +++ b/app/api/show-api/src/main/java/com/example/show/service/dto/response/TicketingAlertReservationServiceResponse.java @@ -9,7 +9,7 @@ import java.util.Set; import java.util.stream.Collectors; import lombok.Builder; -import org.example.entity.TicketingAlert; +import org.example.entity.usershow.TicketingAlert; @Builder public record TicketingAlertReservationServiceResponse( diff --git a/app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfInterestShowServiceResponse.java b/app/api/show-api/src/main/java/com/example/show/service/dto/usershow/response/NumberOfInterestShowServiceResponse.java similarity index 79% rename from app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfInterestShowServiceResponse.java rename to app/api/show-api/src/main/java/com/example/show/service/dto/usershow/response/NumberOfInterestShowServiceResponse.java index fbbd1c50..711bccbb 100644 --- a/app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfInterestShowServiceResponse.java +++ b/app/api/show-api/src/main/java/com/example/show/service/dto/usershow/response/NumberOfInterestShowServiceResponse.java @@ -1,4 +1,4 @@ -package org.example.service.dto.response; +package com.example.show.service.dto.usershow.response; public record NumberOfInterestShowServiceResponse( long count diff --git a/app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfTicketingAlertServiceResponse.java b/app/api/show-api/src/main/java/com/example/show/service/dto/usershow/response/NumberOfTicketingAlertServiceResponse.java similarity index 79% rename from app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfTicketingAlertServiceResponse.java rename to app/api/show-api/src/main/java/com/example/show/service/dto/usershow/response/NumberOfTicketingAlertServiceResponse.java index 5b33ad33..9497e09e 100644 --- a/app/api/user-api/src/main/java/org/example/service/dto/response/NumberOfTicketingAlertServiceResponse.java +++ b/app/api/show-api/src/main/java/com/example/show/service/dto/usershow/response/NumberOfTicketingAlertServiceResponse.java @@ -1,4 +1,4 @@ -package org.example.service.dto.response; +package com.example.show.service.dto.usershow.response; public record NumberOfTicketingAlertServiceResponse( long count diff --git a/app/api/show-api/src/test/java/artist/service/ArtistAdminServiceTest.java b/app/api/show-api/src/test/java/artist/service/ArtistAdminServiceTest.java index de112222..4327669a 100644 --- a/app/api/show-api/src/test/java/artist/service/ArtistAdminServiceTest.java +++ b/app/api/show-api/src/test/java/artist/service/ArtistAdminServiceTest.java @@ -15,7 +15,7 @@ import com.example.component.FileUploadComponent; import java.util.UUID; import org.example.entity.artist.Artist; -import org.example.usecase.artist.ArtistUseCase; +import org.example.usecase.ArtistUseCase; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/app/api/show-api/src/test/java/artist/service/ArtistServiceTest.java b/app/api/show-api/src/test/java/artist/service/ArtistServiceTest.java index b4a5b2d9..68453876 100644 --- a/app/api/show-api/src/test/java/artist/service/ArtistServiceTest.java +++ b/app/api/show-api/src/test/java/artist/service/ArtistServiceTest.java @@ -19,14 +19,13 @@ import java.util.NoSuchElementException; import java.util.UUID; import org.assertj.core.api.SoftAssertions; -import org.example.entity.ArtistSubscription; import org.example.entity.artist.Artist; -import org.example.fixture.ArtistSubscriptionFixture; +import org.example.entity.usershow.ArtistSubscription; import org.example.fixture.domain.ArtistFixture; +import org.example.fixture.domain.ArtistSubscriptionFixture; import org.example.usecase.ArtistSubscriptionUseCase; -import org.example.usecase.UserShowUseCase; +import org.example.usecase.ArtistUseCase; import org.example.usecase.UserUseCase; -import org.example.usecase.artist.ArtistUseCase; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -36,14 +35,12 @@ class ArtistServiceTest { private final ArtistSubscriptionUseCase artistSubscriptionUseCase = mock( ArtistSubscriptionUseCase.class ); - private final UserShowUseCase userShowUseCase = mock(UserShowUseCase.class); private final UserUseCase userUseCase = mock(UserUseCase.class); private final MessagePublisher messagePublisher = mock(MessagePublisher.class); private final ArtistService artistService = new ArtistService( artistUseCase, artistSubscriptionUseCase, - userShowUseCase, userUseCase, messagePublisher ); diff --git a/app/api/show-api/src/test/java/genre/service/GenreServiceTest.java b/app/api/show-api/src/test/java/genre/service/GenreServiceTest.java index f9a0b3b2..7c4ce9f9 100644 --- a/app/api/show-api/src/test/java/genre/service/GenreServiceTest.java +++ b/app/api/show-api/src/test/java/genre/service/GenreServiceTest.java @@ -18,13 +18,13 @@ import java.util.List; import java.util.UUID; import org.assertj.core.api.SoftAssertions; -import org.example.entity.GenreSubscription; import org.example.entity.genre.Genre; -import org.example.fixture.GenreSubscriptionFixture; +import org.example.entity.usershow.GenreSubscription; import org.example.fixture.domain.GenreFixture; +import org.example.fixture.domain.GenreSubscriptionFixture; import org.example.usecase.GenreSubscriptionUseCase; +import org.example.usecase.GenreUseCase; import org.example.usecase.UserUseCase; -import org.example.usecase.genre.GenreUseCase; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/app/api/show-api/src/test/java/show/service/ShowAdminServiceTest.java b/app/api/show-api/src/test/java/show/service/ShowAdminServiceTest.java index 7cd564bb..c9dafa10 100644 --- a/app/api/show-api/src/test/java/show/service/ShowAdminServiceTest.java +++ b/app/api/show-api/src/test/java/show/service/ShowAdminServiceTest.java @@ -20,9 +20,9 @@ import org.example.dto.show.request.ShowUpdateDomainRequest; import org.example.fixture.domain.ShowArtistFixture; import org.example.fixture.domain.ShowGenreFixture; -import org.example.usecase.artist.ArtistUseCase; -import org.example.usecase.genre.GenreUseCase; -import org.example.usecase.show.ShowAdminUseCase; +import org.example.usecase.ArtistUseCase; +import org.example.usecase.GenreUseCase; +import org.example.usecase.ShowAdminUseCase; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import show.fixture.dto.ShowRequestDtoFixture; diff --git a/app/api/show-api/src/test/java/show/service/ShowServiceTest.java b/app/api/show-api/src/test/java/show/service/ShowServiceTest.java index 78fd4631..46a370e4 100644 --- a/app/api/show-api/src/test/java/show/service/ShowServiceTest.java +++ b/app/api/show-api/src/test/java/show/service/ShowServiceTest.java @@ -7,13 +7,11 @@ import static org.mockito.Mockito.verify; import com.example.component.ViewCountComponent; -import com.example.publish.MessagePublisher; import com.example.show.service.ShowService; import java.util.UUID; import org.assertj.core.api.SoftAssertions; -import org.example.usecase.TicketingAlertUseCase; -import org.example.usecase.UserShowUseCase; -import org.example.usecase.show.ShowUseCase; +import org.example.usecase.InterestShowUseCase; +import org.example.usecase.ShowUseCase; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import show.fixture.dto.ShowRequestDtoFixture; @@ -22,15 +20,11 @@ class ShowServiceTest { private final ShowUseCase showUseCase = mock(ShowUseCase.class); - private final UserShowUseCase userShowUseCase = mock(UserShowUseCase.class); - private final TicketingAlertUseCase ticketingAlertUseCase = mock(TicketingAlertUseCase.class); - private final MessagePublisher messagePublisher = mock(MessagePublisher.class); + private final InterestShowUseCase interestShowUseCase = mock(InterestShowUseCase.class); private final ViewCountComponent viewCountComponent = mock(ViewCountComponent.class); private final ShowService showService = new ShowService( showUseCase, - ticketingAlertUseCase, - userShowUseCase, - messagePublisher, + interestShowUseCase, viewCountComponent ); diff --git a/app/api/user-api/build.gradle b/app/api/user-api/build.gradle index a1a7f233..534db387 100644 --- a/app/api/user-api/build.gradle +++ b/app/api/user-api/build.gradle @@ -1,6 +1,6 @@ dependencies { implementation project(":app:domain:user-domain") - + implementation project(":app:domain:show-domain") implementation project(":app:api:common-api") //testFixtures diff --git a/app/api/user-api/src/main/java/org/example/controller/UserShowController.java b/app/api/user-api/src/main/java/org/example/controller/UserShowController.java deleted file mode 100644 index 72a50a84..00000000 --- a/app/api/user-api/src/main/java/org/example/controller/UserShowController.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.example.controller; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import java.time.LocalDateTime; -import lombok.RequiredArgsConstructor; -import org.example.controller.dto.response.NumberOfInterestShowApiResponse; -import org.example.controller.dto.response.NumberOfSubscribedArtistApiResponse; -import org.example.controller.dto.response.NumberOfSubscribedGenreApiResponse; -import org.example.controller.dto.response.NumberOfTicketingAlertApiResponse; -import org.example.security.dto.AuthenticatedUser; -import org.example.service.UserShowService; -import org.springframework.http.ResponseEntity; -import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequiredArgsConstructor -@RequestMapping("/api/v1/users") -@Tag(name = "유저 공연") -public class UserShowController { - - private final UserShowService userShowService; - - @GetMapping("/shows/alerts/count") - @Operation(summary = "알림 설정한 공연 개수") - public ResponseEntity getNumberOfAlertShow( - @AuthenticationPrincipal AuthenticatedUser user - ) { - LocalDateTime now = LocalDateTime.now(); - return ResponseEntity.ok( - NumberOfTicketingAlertApiResponse.from( - userShowService.countAlertShows(user.userId(), now) - ) - ); - } - - @GetMapping("/artists/subscriptions/count") - @Operation(summary = "구독한 아티스트 수") - public ResponseEntity getNumberOfSubscribedArtist( - @AuthenticationPrincipal AuthenticatedUser user - ) { - return ResponseEntity.ok( - NumberOfSubscribedArtistApiResponse.from( - userShowService.countSubscribedArtists(user.userId()) - ) - ); - } - - @GetMapping("/genres/subscriptions/count") - @Operation(summary = "구독한 장르 수") - public ResponseEntity getNumberOfSubscribedGenre( - @AuthenticationPrincipal AuthenticatedUser user - ) { - return ResponseEntity.ok( - NumberOfSubscribedGenreApiResponse.from( - userShowService.countSubscribedGenres(user.userId()) - ) - ); - } - - @GetMapping("/shows/interests/count") - @Operation(summary = "관심 공연 개수") - public ResponseEntity getNumberOfInterestShow( - @AuthenticationPrincipal AuthenticatedUser user - ) { - return ResponseEntity.ok( - NumberOfInterestShowApiResponse.from( - userShowService.countInterestShows(user.userId()) - ) - ); - } -} diff --git a/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfInterestShowApiResponse.java b/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfInterestShowApiResponse.java deleted file mode 100644 index 13256dea..00000000 --- a/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfInterestShowApiResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.example.controller.dto.response; - -import org.example.service.dto.response.NumberOfInterestShowServiceResponse; - -public record NumberOfInterestShowApiResponse( - long count -) { - - public static NumberOfInterestShowApiResponse from(NumberOfInterestShowServiceResponse response) { - return new NumberOfInterestShowApiResponse(response.count()); - } -} diff --git a/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfSubscribedArtistApiResponse.java b/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfSubscribedArtistApiResponse.java deleted file mode 100644 index 7901df75..00000000 --- a/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfSubscribedArtistApiResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.example.controller.dto.response; - -import org.example.service.dto.response.NumberOfSubscribedArtistServiceResponse; - -public record NumberOfSubscribedArtistApiResponse( - long count -) { - - public static NumberOfSubscribedArtistApiResponse from(NumberOfSubscribedArtistServiceResponse response) { - return new NumberOfSubscribedArtistApiResponse(response.count()); - } -} diff --git a/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfSubscribedGenreApiResponse.java b/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfSubscribedGenreApiResponse.java deleted file mode 100644 index 9ac46b98..00000000 --- a/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfSubscribedGenreApiResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.example.controller.dto.response; - -import org.example.service.dto.response.NumberOfSubscribedGenreServiceResponse; - -public record NumberOfSubscribedGenreApiResponse( - long count -) { - - public static NumberOfSubscribedGenreApiResponse from(NumberOfSubscribedGenreServiceResponse response) { - return new NumberOfSubscribedGenreApiResponse(response.count()); - } -} diff --git a/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfTicketingAlertApiResponse.java b/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfTicketingAlertApiResponse.java deleted file mode 100644 index 48dda393..00000000 --- a/app/api/user-api/src/main/java/org/example/controller/dto/response/NumberOfTicketingAlertApiResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.example.controller.dto.response; - -import org.example.service.dto.response.NumberOfTicketingAlertServiceResponse; - -public record NumberOfTicketingAlertApiResponse( - long count -) { - - public static NumberOfTicketingAlertApiResponse from(NumberOfTicketingAlertServiceResponse response) { - return new NumberOfTicketingAlertApiResponse(response.count()); - } -} diff --git a/app/api/user-api/src/main/java/org/example/service/UserService.java b/app/api/user-api/src/main/java/org/example/service/UserService.java index 133bfe1d..7ab41822 100644 --- a/app/api/user-api/src/main/java/org/example/service/UserService.java +++ b/app/api/user-api/src/main/java/org/example/service/UserService.java @@ -16,16 +16,26 @@ import org.example.service.dto.request.ReissueServiceRequest; import org.example.service.dto.request.WithdrawalServiceRequest; import org.example.service.dto.response.UserProfileServiceResponse; +import org.example.usecase.ArtistSubscriptionUseCase; +import org.example.usecase.GenreSubscriptionUseCase; +import org.example.usecase.InterestShowUseCase; +import org.example.usecase.TicketingAlertUseCase; import org.example.usecase.UserUseCase; import org.springframework.stereotype.Service; +import org.springframework.transaction.support.TransactionTemplate; @Service @RequiredArgsConstructor public class UserService { private final UserUseCase userUseCase; + private final ArtistSubscriptionUseCase artistSubscriptionUseCase; + private final GenreSubscriptionUseCase genreSubscriptionUseCase; + private final InterestShowUseCase interestShowUseCase; + private final TicketingAlertUseCase ticketingAlertUseCase; private final JWTGenerator jwtGenerator; private final TokenProcessor tokenProcessor; + private final TransactionTemplate transactionTemplate; public TokenParam login(LoginServiceRequest loginServiceRequest) { User user = getUser(loginServiceRequest); @@ -42,7 +52,10 @@ public void logout(LogoutServiceRequest request) { } public void withdraw(WithdrawalServiceRequest request) { - userUseCase.deleteUser(request.userId()); + transactionTemplate.executeWithoutResult(status -> { + User user = userUseCase.deleteUser(request.userId()); + deleteAssociatedWithUser(user); + }); tokenProcessor.makeAccessTokenBlacklistAndDeleteRefreshToken( request.accessToken(), @@ -78,4 +91,11 @@ private User createUser(LoginServiceRequest loginServiceRequest) { return userUseCase.createNewUser(user, socialLogin); } + + private void deleteAssociatedWithUser(User user) { + artistSubscriptionUseCase.deleteAllByUserId(user.getId()); + genreSubscriptionUseCase.deleteAllByUserId(user.getId()); + interestShowUseCase.deleteAllByUserId(user.getId()); + ticketingAlertUseCase.deleteAllByUserId(user.getId()); + } } diff --git a/app/api/user-api/src/main/java/org/example/service/UserShowService.java b/app/api/user-api/src/main/java/org/example/service/UserShowService.java deleted file mode 100644 index e1ab40d0..00000000 --- a/app/api/user-api/src/main/java/org/example/service/UserShowService.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.example.service; - -import java.time.LocalDateTime; -import java.util.UUID; -import lombok.RequiredArgsConstructor; -import org.example.service.dto.response.NumberOfInterestShowServiceResponse; -import org.example.service.dto.response.NumberOfSubscribedArtistServiceResponse; -import org.example.service.dto.response.NumberOfSubscribedGenreServiceResponse; -import org.example.service.dto.response.NumberOfTicketingAlertServiceResponse; -import org.example.usecase.UserShowUseCase; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class UserShowService { - - private final UserShowUseCase userShowUseCase; - - public NumberOfTicketingAlertServiceResponse countAlertShows(UUID userId, LocalDateTime now) { - long numberOfTicketingAlert = userShowUseCase.countAlertShows(userId, now); - - return NumberOfTicketingAlertServiceResponse.from(numberOfTicketingAlert); - } - - public NumberOfSubscribedArtistServiceResponse countSubscribedArtists(UUID userId) { - return NumberOfSubscribedArtistServiceResponse.from( - userShowUseCase.countSubscribedArtists(userId) - ); - } - - public NumberOfSubscribedGenreServiceResponse countSubscribedGenres(UUID uuid) { - return NumberOfSubscribedGenreServiceResponse.from( - userShowUseCase.countSubscribedGenres(uuid) - ); - } - - public NumberOfInterestShowServiceResponse countInterestShows(UUID uuid) { - return NumberOfInterestShowServiceResponse.from( - userShowUseCase.countInterestShows(uuid) - ); - } -} diff --git a/app/api/user-api/src/test/java/org/example/service/UserServiceTest.java b/app/api/user-api/src/test/java/org/example/service/UserServiceTest.java index 44b60d8b..e160aa61 100644 --- a/app/api/user-api/src/test/java/org/example/service/UserServiceTest.java +++ b/app/api/user-api/src/test/java/org/example/service/UserServiceTest.java @@ -15,6 +15,10 @@ import org.example.security.dto.UserParam; import org.example.security.token.JWTGenerator; import org.example.security.token.TokenProcessor; +import org.example.usecase.ArtistSubscriptionUseCase; +import org.example.usecase.GenreSubscriptionUseCase; +import org.example.usecase.InterestShowUseCase; +import org.example.usecase.TicketingAlertUseCase; import org.example.usecase.UserUseCase; import org.example.vo.SocialLoginApiType; import org.junit.jupiter.api.DisplayName; @@ -22,17 +26,28 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.EnumSource.Mode; +import org.springframework.transaction.support.TransactionTemplate; public class UserServiceTest { private final UserUseCase userUseCase = mock(UserUseCase.class); + private final ArtistSubscriptionUseCase artistSubscriptionUseCase = mock(ArtistSubscriptionUseCase.class); + private final GenreSubscriptionUseCase genreSubscriptionUseCase = mock(GenreSubscriptionUseCase.class); + private final InterestShowUseCase interestShowUseCase = mock(InterestShowUseCase.class); + private final TicketingAlertUseCase ticketingAlertUseCase = mock(TicketingAlertUseCase.class); private final JWTGenerator jwtGenerator = mock(JWTGenerator.class); private final TokenProcessor tokenProcessor = mock(TokenProcessor.class); + private final TransactionTemplate transactionTemplate = mock(TransactionTemplate.class); private final UserService userService = new UserService( userUseCase, + artistSubscriptionUseCase, + genreSubscriptionUseCase, + interestShowUseCase, + ticketingAlertUseCase, jwtGenerator, - tokenProcessor + tokenProcessor, + transactionTemplate ); @ParameterizedTest diff --git a/app/domain/show-domain/src/main/java/org/example/config/ShowDomainConfig.java b/app/domain/show-domain/src/main/java/org/example/config/ShowDomainConfig.java index 3d25be66..fb513f2a 100644 --- a/app/domain/show-domain/src/main/java/org/example/config/ShowDomainConfig.java +++ b/app/domain/show-domain/src/main/java/org/example/config/ShowDomainConfig.java @@ -11,7 +11,10 @@ @EnableJpaRepositories(basePackages = { "org.example.repository.genre", "org.example.repository.artist", - "org.example.repository.show" + "org.example.repository.show", + "org.example.repository.subscription", + "org.example.repository.interest", + "org.example.repository.ticketing" } ) public class ShowDomainConfig { diff --git a/app/domain/user-domain/src/main/java/org/example/dto/request/InterestShowDomainRequest.java b/app/domain/show-domain/src/main/java/org/example/dto/usershow/request/InterestShowDomainRequest.java similarity index 76% rename from app/domain/user-domain/src/main/java/org/example/dto/request/InterestShowDomainRequest.java rename to app/domain/show-domain/src/main/java/org/example/dto/usershow/request/InterestShowDomainRequest.java index 3c7e3cbd..9c08402d 100644 --- a/app/domain/user-domain/src/main/java/org/example/dto/request/InterestShowDomainRequest.java +++ b/app/domain/show-domain/src/main/java/org/example/dto/usershow/request/InterestShowDomainRequest.java @@ -1,4 +1,4 @@ -package org.example.dto.request; +package org.example.dto.usershow.request; import java.util.UUID; import lombok.Builder; diff --git a/app/domain/user-domain/src/main/java/org/example/dto/request/InterestShowPaginationDomainRequest.java b/app/domain/show-domain/src/main/java/org/example/dto/usershow/request/InterestShowPaginationDomainRequest.java similarity index 84% rename from app/domain/user-domain/src/main/java/org/example/dto/request/InterestShowPaginationDomainRequest.java rename to app/domain/show-domain/src/main/java/org/example/dto/usershow/request/InterestShowPaginationDomainRequest.java index 41b7732e..02b7f64b 100644 --- a/app/domain/user-domain/src/main/java/org/example/dto/request/InterestShowPaginationDomainRequest.java +++ b/app/domain/show-domain/src/main/java/org/example/dto/usershow/request/InterestShowPaginationDomainRequest.java @@ -1,4 +1,4 @@ -package org.example.dto.request; +package org.example.dto.usershow.request; import java.time.LocalDateTime; import java.util.UUID; diff --git a/app/domain/user-domain/src/main/java/org/example/dto/request/TicketingAlertReservationDomainRequest.java b/app/domain/show-domain/src/main/java/org/example/dto/usershow/request/TicketingAlertReservationDomainRequest.java similarity index 90% rename from app/domain/user-domain/src/main/java/org/example/dto/request/TicketingAlertReservationDomainRequest.java rename to app/domain/show-domain/src/main/java/org/example/dto/usershow/request/TicketingAlertReservationDomainRequest.java index 4a08b78d..8fa6505b 100644 --- a/app/domain/user-domain/src/main/java/org/example/dto/request/TicketingAlertReservationDomainRequest.java +++ b/app/domain/show-domain/src/main/java/org/example/dto/usershow/request/TicketingAlertReservationDomainRequest.java @@ -1,4 +1,4 @@ -package org.example.dto.request; +package org.example.dto.usershow.request; import java.time.LocalDateTime; import java.util.List; diff --git a/app/domain/user-domain/src/main/java/org/example/dto/response/InterestShowPaginationDomainResponse.java b/app/domain/show-domain/src/main/java/org/example/dto/usershow/response/InterestShowPaginationDomainResponse.java similarity index 64% rename from app/domain/user-domain/src/main/java/org/example/dto/response/InterestShowPaginationDomainResponse.java rename to app/domain/show-domain/src/main/java/org/example/dto/usershow/response/InterestShowPaginationDomainResponse.java index 8d3a4225..2af364cf 100644 --- a/app/domain/user-domain/src/main/java/org/example/dto/response/InterestShowPaginationDomainResponse.java +++ b/app/domain/show-domain/src/main/java/org/example/dto/usershow/response/InterestShowPaginationDomainResponse.java @@ -1,8 +1,8 @@ -package org.example.dto.response; +package org.example.dto.usershow.response; import java.util.List; import lombok.Builder; -import org.example.entity.InterestShow; +import org.example.entity.usershow.InterestShow; @Builder public record InterestShowPaginationDomainResponse( diff --git a/app/domain/user-domain/src/main/java/org/example/dto/response/TicketingAlertsDomainResponse.java b/app/domain/show-domain/src/main/java/org/example/dto/usershow/response/TicketingAlertsDomainResponse.java similarity index 81% rename from app/domain/user-domain/src/main/java/org/example/dto/response/TicketingAlertsDomainResponse.java rename to app/domain/show-domain/src/main/java/org/example/dto/usershow/response/TicketingAlertsDomainResponse.java index 56c8f938..8d8873ac 100644 --- a/app/domain/user-domain/src/main/java/org/example/dto/response/TicketingAlertsDomainResponse.java +++ b/app/domain/show-domain/src/main/java/org/example/dto/usershow/response/TicketingAlertsDomainResponse.java @@ -1,4 +1,4 @@ -package org.example.dto.response; +package org.example.dto.usershow.response; import java.util.List; import java.util.UUID; @@ -6,8 +6,6 @@ @Builder public record TicketingAlertsDomainResponse( - - String userFcmToken, String name, UUID showId, List addAts, diff --git a/app/domain/user-domain/src/main/java/org/example/dto/response/TicketingTimeDomainResponse.java b/app/domain/show-domain/src/main/java/org/example/dto/usershow/response/TicketingTimeDomainResponse.java similarity index 92% rename from app/domain/user-domain/src/main/java/org/example/dto/response/TicketingTimeDomainResponse.java rename to app/domain/show-domain/src/main/java/org/example/dto/usershow/response/TicketingTimeDomainResponse.java index cfdf9db2..2d256125 100644 --- a/app/domain/user-domain/src/main/java/org/example/dto/response/TicketingTimeDomainResponse.java +++ b/app/domain/show-domain/src/main/java/org/example/dto/usershow/response/TicketingTimeDomainResponse.java @@ -1,4 +1,4 @@ -package org.example.dto.response; +package org.example.dto.usershow.response; import java.time.LocalDateTime; import lombok.Builder; diff --git a/app/domain/user-domain/src/main/java/org/example/entity/ArtistSubscription.java b/app/domain/show-domain/src/main/java/org/example/entity/usershow/ArtistSubscription.java similarity index 91% rename from app/domain/user-domain/src/main/java/org/example/entity/ArtistSubscription.java rename to app/domain/show-domain/src/main/java/org/example/entity/usershow/ArtistSubscription.java index 2bb8b6e8..430a9df2 100644 --- a/app/domain/user-domain/src/main/java/org/example/entity/ArtistSubscription.java +++ b/app/domain/show-domain/src/main/java/org/example/entity/usershow/ArtistSubscription.java @@ -1,4 +1,4 @@ -package org.example.entity; +package org.example.entity.usershow; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -8,6 +8,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.example.entity.BaseEntity; @Entity @Getter diff --git a/app/domain/user-domain/src/main/java/org/example/entity/GenreSubscription.java b/app/domain/show-domain/src/main/java/org/example/entity/usershow/GenreSubscription.java similarity index 91% rename from app/domain/user-domain/src/main/java/org/example/entity/GenreSubscription.java rename to app/domain/show-domain/src/main/java/org/example/entity/usershow/GenreSubscription.java index 22b32687..1d060861 100644 --- a/app/domain/user-domain/src/main/java/org/example/entity/GenreSubscription.java +++ b/app/domain/show-domain/src/main/java/org/example/entity/usershow/GenreSubscription.java @@ -1,4 +1,4 @@ -package org.example.entity; +package org.example.entity.usershow; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -8,6 +8,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.example.entity.BaseEntity; @Entity @Getter diff --git a/app/domain/user-domain/src/main/java/org/example/entity/InterestShow.java b/app/domain/show-domain/src/main/java/org/example/entity/usershow/InterestShow.java similarity index 92% rename from app/domain/user-domain/src/main/java/org/example/entity/InterestShow.java rename to app/domain/show-domain/src/main/java/org/example/entity/usershow/InterestShow.java index 2823cabc..83061cb2 100644 --- a/app/domain/user-domain/src/main/java/org/example/entity/InterestShow.java +++ b/app/domain/show-domain/src/main/java/org/example/entity/usershow/InterestShow.java @@ -1,4 +1,4 @@ -package org.example.entity; +package org.example.entity.usershow; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -8,6 +8,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.example.entity.BaseEntity; @Entity @Getter diff --git a/app/domain/user-domain/src/main/java/org/example/entity/TicketingAlert.java b/app/domain/show-domain/src/main/java/org/example/entity/usershow/TicketingAlert.java similarity index 93% rename from app/domain/user-domain/src/main/java/org/example/entity/TicketingAlert.java rename to app/domain/show-domain/src/main/java/org/example/entity/usershow/TicketingAlert.java index 0007ab39..424fe773 100644 --- a/app/domain/user-domain/src/main/java/org/example/entity/TicketingAlert.java +++ b/app/domain/show-domain/src/main/java/org/example/entity/usershow/TicketingAlert.java @@ -1,4 +1,4 @@ -package org.example.entity; +package org.example.entity.usershow; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -9,6 +9,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.example.entity.BaseEntity; @Entity @Getter diff --git a/app/domain/show-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepository.java b/app/domain/show-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepository.java new file mode 100644 index 00000000..b94f4a2f --- /dev/null +++ b/app/domain/show-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepository.java @@ -0,0 +1,11 @@ +package org.example.repository.interest; + +import org.example.dto.usershow.request.InterestShowPaginationDomainRequest; +import org.example.dto.usershow.response.InterestShowPaginationDomainResponse; + +public interface InterestShowQuerydslRepository { + + InterestShowPaginationDomainResponse findInterestShowList( + InterestShowPaginationDomainRequest request + ); +} diff --git a/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java b/app/domain/show-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java similarity index 67% rename from app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java rename to app/domain/show-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java index 2c3c9010..4452b482 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepositoryImpl.java @@ -1,16 +1,14 @@ package org.example.repository.interest; -import static org.example.entity.QInterestShow.interestShow; -import static org.example.entity.QTicketingAlert.ticketingAlert; + +import static org.example.entity.usershow.QInterestShow.interestShow; 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; -import org.example.entity.InterestShow; +import org.example.dto.usershow.request.InterestShowPaginationDomainRequest; +import org.example.dto.usershow.response.InterestShowPaginationDomainResponse; +import org.example.entity.usershow.InterestShow; import org.example.util.SliceUtil; import org.springframework.data.domain.Slice; import org.springframework.stereotype.Repository; @@ -42,21 +40,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/interest/InterestShowRepository.java b/app/domain/show-domain/src/main/java/org/example/repository/interest/InterestShowRepository.java similarity index 91% rename from app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowRepository.java rename to app/domain/show-domain/src/main/java/org/example/repository/interest/InterestShowRepository.java index bcf8f042..fbc089f7 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowRepository.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/interest/InterestShowRepository.java @@ -2,7 +2,7 @@ import java.util.Optional; import java.util.UUID; -import org.example.entity.InterestShow; +import org.example.entity.usershow.InterestShow; import org.springframework.data.jpa.repository.JpaRepository; public interface InterestShowRepository extends JpaRepository, InterestShowQuerydslRepository { diff --git a/app/domain/user-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepository.java b/app/domain/show-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepository.java similarity index 81% rename from app/domain/user-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepository.java rename to app/domain/show-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepository.java index ac028ac9..0480dcc4 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepository.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepository.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.UUID; -import org.example.entity.ArtistSubscription; +import org.example.entity.usershow.ArtistSubscription; public interface ArtistSubscriptionQuerydslRepository { diff --git a/app/domain/user-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepositoryImpl.java b/app/domain/show-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepositoryImpl.java similarity index 84% rename from app/domain/user-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepositoryImpl.java rename to app/domain/show-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepositoryImpl.java index 97c3d1ab..ee2ab1b8 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepositoryImpl.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionQuerydslRepositoryImpl.java @@ -1,12 +1,13 @@ package org.example.repository.subscription.artistsubscription; -import static org.example.entity.QArtistSubscription.artistSubscription; + +import static org.example.entity.usershow.QArtistSubscription.artistSubscription; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; -import org.example.entity.ArtistSubscription; +import org.example.entity.usershow.ArtistSubscription; import org.springframework.stereotype.Repository; @Repository diff --git a/app/domain/user-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionRepository.java b/app/domain/show-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionRepository.java similarity index 90% rename from app/domain/user-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionRepository.java rename to app/domain/show-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionRepository.java index dabde51a..860d058f 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionRepository.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/subscription/artistsubscription/ArtistSubscriptionRepository.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.UUID; -import org.example.entity.ArtistSubscription; +import org.example.entity.usershow.ArtistSubscription; import org.springframework.data.jpa.repository.JpaRepository; public interface ArtistSubscriptionRepository diff --git a/app/domain/user-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepository.java b/app/domain/show-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepository.java similarity index 81% rename from app/domain/user-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepository.java rename to app/domain/show-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepository.java index e3ffb9e5..ee572727 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepository.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepository.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.UUID; -import org.example.entity.GenreSubscription; +import org.example.entity.usershow.GenreSubscription; public interface GenreSubscriptionQuerydslRepository { diff --git a/app/domain/user-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepositoryImpl.java b/app/domain/show-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepositoryImpl.java similarity index 73% rename from app/domain/user-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepositoryImpl.java rename to app/domain/show-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepositoryImpl.java index de13281a..737d3652 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepositoryImpl.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionQuerydslRepositoryImpl.java @@ -1,18 +1,18 @@ package org.example.repository.subscription.genresubscription; -import static org.example.entity.QGenreSubscription.genreSubscription; + +import static org.example.entity.usershow.QGenreSubscription.genreSubscription; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; -import org.example.entity.GenreSubscription; +import org.example.entity.usershow.GenreSubscription; import org.springframework.stereotype.Repository; @Repository @RequiredArgsConstructor -public class GenreSubscriptionQuerydslRepositoryImpl implements - GenreSubscriptionQuerydslRepository { +public class GenreSubscriptionQuerydslRepositoryImpl implements GenreSubscriptionQuerydslRepository { private final JPAQueryFactory jpaQueryFactory; diff --git a/app/domain/user-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionRepository.java b/app/domain/show-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionRepository.java similarity index 90% rename from app/domain/user-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionRepository.java rename to app/domain/show-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionRepository.java index f961d926..c7ad6f01 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionRepository.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/subscription/genresubscription/GenreSubscriptionRepository.java @@ -2,9 +2,10 @@ import java.util.List; import java.util.UUID; -import org.example.entity.GenreSubscription; +import org.example.entity.usershow.GenreSubscription; import org.springframework.data.jpa.repository.JpaRepository; + public interface GenreSubscriptionRepository extends JpaRepository, GenreSubscriptionQuerydslRepository { diff --git a/app/domain/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepository.java b/app/domain/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepository.java new file mode 100644 index 00000000..439bac10 --- /dev/null +++ b/app/domain/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepository.java @@ -0,0 +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/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepositoryImpl.java b/app/domain/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepositoryImpl.java new file mode 100644 index 00000000..f2f29140 --- /dev/null +++ b/app/domain/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepositoryImpl.java @@ -0,0 +1,31 @@ +package org.example.repository.ticketing; + + +import static org.example.entity.usershow.QTicketingAlert.ticketingAlert; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import java.time.LocalDateTime; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; + +@Repository +@RequiredArgsConstructor +public class TicketingAlertQuerydslRepositoryImpl implements TicketingAlertQuerydslRepository { + + 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/repository/ticketing/TicketingAlertRepository.java b/app/domain/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertRepository.java similarity index 90% rename from app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertRepository.java rename to app/domain/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertRepository.java index c735f101..a82061fc 100644 --- a/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertRepository.java +++ b/app/domain/show-domain/src/main/java/org/example/repository/ticketing/TicketingAlertRepository.java @@ -2,9 +2,10 @@ import java.util.List; import java.util.UUID; -import org.example.entity.TicketingAlert; +import org.example.entity.usershow.TicketingAlert; import org.springframework.data.jpa.repository.JpaRepository; + public interface TicketingAlertRepository extends JpaRepository, TicketingAlertQuerydslRepository { diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/ArtistSubscriptionUseCase.java b/app/domain/show-domain/src/main/java/org/example/usecase/ArtistSubscriptionUseCase.java similarity index 80% rename from app/domain/user-domain/src/main/java/org/example/usecase/ArtistSubscriptionUseCase.java rename to app/domain/show-domain/src/main/java/org/example/usecase/ArtistSubscriptionUseCase.java index b2c3a3d2..b30ab40e 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/ArtistSubscriptionUseCase.java +++ b/app/domain/show-domain/src/main/java/org/example/usecase/ArtistSubscriptionUseCase.java @@ -5,7 +5,7 @@ import java.util.UUID; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; -import org.example.entity.ArtistSubscription; +import org.example.entity.usershow.ArtistSubscription; import org.example.repository.subscription.artistsubscription.ArtistSubscriptionRepository; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -59,4 +59,18 @@ public List unsubscribe(List artistIds, UUID userId) { return filteredSubscription; } + + public List findArtistSubscriptionByUserId(UUID userId) { + return artistSubscriptionRepository.findAllByUserIdAndIsDeletedFalse(userId); + } + + + public long countSubscribedArtists(UUID userId) { + Long result = artistSubscriptionRepository.countByUserIdAndIsDeletedFalse(userId); + return result == null ? 0 : result; + } + + public void deleteAllByUserId(UUID userId) { + artistSubscriptionRepository.deleteAllByUserId(userId); + } } diff --git a/app/domain/show-domain/src/main/java/org/example/usecase/artist/ArtistUseCase.java b/app/domain/show-domain/src/main/java/org/example/usecase/ArtistUseCase.java similarity index 99% rename from app/domain/show-domain/src/main/java/org/example/usecase/artist/ArtistUseCase.java rename to app/domain/show-domain/src/main/java/org/example/usecase/ArtistUseCase.java index 73da4c7b..f75451e7 100644 --- a/app/domain/show-domain/src/main/java/org/example/usecase/artist/ArtistUseCase.java +++ b/app/domain/show-domain/src/main/java/org/example/usecase/ArtistUseCase.java @@ -1,4 +1,4 @@ -package org.example.usecase.artist; +package org.example.usecase; import java.util.List; import java.util.NoSuchElementException; diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/GenreSubscriptionUseCase.java b/app/domain/show-domain/src/main/java/org/example/usecase/GenreSubscriptionUseCase.java similarity index 85% rename from app/domain/user-domain/src/main/java/org/example/usecase/GenreSubscriptionUseCase.java rename to app/domain/show-domain/src/main/java/org/example/usecase/GenreSubscriptionUseCase.java index ea840696..75794253 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/GenreSubscriptionUseCase.java +++ b/app/domain/show-domain/src/main/java/org/example/usecase/GenreSubscriptionUseCase.java @@ -5,7 +5,7 @@ import java.util.UUID; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; -import org.example.entity.GenreSubscription; +import org.example.entity.usershow.GenreSubscription; import org.example.repository.subscription.genresubscription.GenreSubscriptionRepository; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -59,4 +59,13 @@ public List unsubscribe(List genreIds, UUID userId) { return filteredSubscriptions; } + + public long countSubscribedGenres(UUID userId) { + Long result = genreSubscriptionRepository.countByUserIdAndIsDeletedFalse(userId); + return result == null ? 0 : result; + } + + public void deleteAllByUserId(UUID userId) { + genreSubscriptionRepository.deleteAllByUserId(userId); + } } diff --git a/app/domain/show-domain/src/main/java/org/example/usecase/genre/GenreUseCase.java b/app/domain/show-domain/src/main/java/org/example/usecase/GenreUseCase.java similarity index 98% rename from app/domain/show-domain/src/main/java/org/example/usecase/genre/GenreUseCase.java rename to app/domain/show-domain/src/main/java/org/example/usecase/GenreUseCase.java index d8a20feb..2b446e6f 100644 --- a/app/domain/show-domain/src/main/java/org/example/usecase/genre/GenreUseCase.java +++ b/app/domain/show-domain/src/main/java/org/example/usecase/GenreUseCase.java @@ -1,4 +1,4 @@ -package org.example.usecase.genre; +package org.example.usecase; import java.util.List; import java.util.NoSuchElementException; diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/UserShowUseCase.java b/app/domain/show-domain/src/main/java/org/example/usecase/InterestShowUseCase.java similarity index 52% rename from app/domain/user-domain/src/main/java/org/example/usecase/UserShowUseCase.java rename to app/domain/show-domain/src/main/java/org/example/usecase/InterestShowUseCase.java index 7f600e91..336e02f7 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/UserShowUseCase.java +++ b/app/domain/show-domain/src/main/java/org/example/usecase/InterestShowUseCase.java @@ -1,32 +1,28 @@ package org.example.usecase; -import java.time.LocalDateTime; -import java.util.List; import java.util.Optional; import java.util.UUID; import lombok.RequiredArgsConstructor; -import org.example.dto.request.InterestShowDomainRequest; -import org.example.dto.request.InterestShowPaginationDomainRequest; -import org.example.dto.response.InterestShowPaginationDomainResponse; -import org.example.entity.ArtistSubscription; -import org.example.entity.InterestShow; +import org.example.dto.usershow.request.InterestShowDomainRequest; +import org.example.dto.usershow.request.InterestShowPaginationDomainRequest; +import org.example.dto.usershow.response.InterestShowPaginationDomainResponse; +import org.example.entity.usershow.InterestShow; import org.example.repository.interest.InterestShowRepository; -import org.example.repository.subscription.artistsubscription.ArtistSubscriptionRepository; -import org.example.repository.subscription.genresubscription.GenreSubscriptionRepository; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @Component @RequiredArgsConstructor -public class UserShowUseCase { +public class InterestShowUseCase { private final InterestShowRepository interestShowRepository; - private final ArtistSubscriptionRepository artistSubscriptionRepository; - private final GenreSubscriptionRepository genreSubscriptionRepository; @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( @@ -47,33 +43,20 @@ public Optional findInterestShow(UUID showId, UUID userId) { return interestShowRepository.findByShowIdAndUserIdAndIsDeletedFalse(showId, userId); } - public List findArtistSubscriptionByUserId(UUID userId) { - return artistSubscriptionRepository.findAllByUserIdAndIsDeletedFalse(userId); - } - - public InterestShowPaginationDomainResponse findInterestShows(InterestShowPaginationDomainRequest request) { + public InterestShowPaginationDomainResponse findInterestShows( + InterestShowPaginationDomainRequest request) { return interestShowRepository.findInterestShowList(request); } - public long countAlertShows(UUID userId, LocalDateTime now) { - return interestShowRepository.countValidTicketingAlerts(userId, now); - } - - public long countSubscribedArtists(UUID userId) { - Long result = artistSubscriptionRepository.countByUserIdAndIsDeletedFalse(userId); - return result == null ? 0 : result; - } - - public long countSubscribedGenres(UUID userId) { - Long result = genreSubscriptionRepository.countByUserIdAndIsDeletedFalse(userId); - return result == null ? 0 : result; - } - public long countInterestShows(UUID userId) { Long result = interestShowRepository.countInterestShowByUserIdAndIsDeletedFalse(userId); return result == null ? 0 : result; } + public void deleteAllByUserId(UUID userId) { + interestShowRepository.deleteAllByUserId(userId); + } + private Optional findInterestShowByShowIdAndUserId(UUID showId, UUID userId) { return interestShowRepository.findByShowIdAndUserId(showId, userId); } diff --git a/app/domain/show-domain/src/main/java/org/example/usecase/show/ShowAdminUseCase.java b/app/domain/show-domain/src/main/java/org/example/usecase/ShowAdminUseCase.java similarity index 99% rename from app/domain/show-domain/src/main/java/org/example/usecase/show/ShowAdminUseCase.java rename to app/domain/show-domain/src/main/java/org/example/usecase/ShowAdminUseCase.java index f7e8ce07..70d2f197 100644 --- a/app/domain/show-domain/src/main/java/org/example/usecase/show/ShowAdminUseCase.java +++ b/app/domain/show-domain/src/main/java/org/example/usecase/ShowAdminUseCase.java @@ -1,4 +1,4 @@ -package org.example.usecase.show; +package org.example.usecase; import java.util.List; import java.util.NoSuchElementException; 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/ShowUseCase.java similarity index 98% rename from app/domain/show-domain/src/main/java/org/example/usecase/show/ShowUseCase.java rename to app/domain/show-domain/src/main/java/org/example/usecase/ShowUseCase.java index 66bb0026..f7a68d74 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/ShowUseCase.java @@ -1,4 +1,4 @@ -package org.example.usecase.show; +package org.example.usecase; import java.time.LocalDateTime; import java.util.List; diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/TicketingAlertUseCase.java b/app/domain/show-domain/src/main/java/org/example/usecase/TicketingAlertUseCase.java similarity index 87% rename from app/domain/user-domain/src/main/java/org/example/usecase/TicketingAlertUseCase.java rename to app/domain/show-domain/src/main/java/org/example/usecase/TicketingAlertUseCase.java index 48bda58d..b00461c4 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/TicketingAlertUseCase.java +++ b/app/domain/show-domain/src/main/java/org/example/usecase/TicketingAlertUseCase.java @@ -2,16 +2,14 @@ import java.time.LocalDateTime; import java.util.List; -import java.util.NoSuchElementException; import java.util.UUID; import lombok.RequiredArgsConstructor; -import org.example.dto.request.TicketingAlertReservationDomainRequest; -import org.example.dto.response.TicketingAlertsDomainResponse; -import org.example.dto.response.TicketingTimeDomainResponse; +import org.example.dto.usershow.request.TicketingAlertReservationDomainRequest; +import org.example.dto.usershow.response.TicketingAlertsDomainResponse; +import org.example.dto.usershow.response.TicketingTimeDomainResponse; import org.example.entity.BaseEntity; -import org.example.entity.TicketingAlert; +import org.example.entity.usershow.TicketingAlert; import org.example.repository.ticketing.TicketingAlertRepository; -import org.example.repository.user.UserRepository; import org.example.vo.TicketingAlertTime; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -21,7 +19,6 @@ public class TicketingAlertUseCase { private final TicketingAlertRepository ticketingAlertRepository; - private final UserRepository userRepository; public List findTicketingAlerts( UUID userId, @@ -34,6 +31,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 @@ -56,12 +57,7 @@ public TicketingAlertsDomainResponse alertReservation( .map(TicketingAlert::getAlertTime) .toList(); - String fcmToken = userRepository.findUserFcmTokensByUserId( - ticketingAlertReservation.userId()) - .orElseThrow(NoSuchElementException::new); - return TicketingAlertsDomainResponse.builder() - .userFcmToken(fcmToken) .name(ticketingAlertReservation.name()) .showId(ticketingAlertReservation.showId()) .addAts(addAlerts(ticketingAlertReservation, requestedAlertTimes, existingAlertTimes)) @@ -69,6 +65,10 @@ public TicketingAlertsDomainResponse alertReservation( .build(); } + public void deleteAllByUserId(UUID userId) { + ticketingAlertRepository.deleteAllByUserId(userId); + } + private List addAlerts( TicketingAlertReservationDomainRequest ticketingAlertReservation, List requestedAlertTimes, diff --git a/app/domain/user-domain/src/main/java/org/example/vo/TicketingAlertTime.java b/app/domain/show-domain/src/main/java/org/example/vo/TicketingAlertTime.java similarity index 72% rename from app/domain/user-domain/src/main/java/org/example/vo/TicketingAlertTime.java rename to app/domain/show-domain/src/main/java/org/example/vo/TicketingAlertTime.java index d15e4ca5..f811bd45 100644 --- a/app/domain/user-domain/src/main/java/org/example/vo/TicketingAlertTime.java +++ b/app/domain/show-domain/src/main/java/org/example/vo/TicketingAlertTime.java @@ -16,11 +16,11 @@ public enum TicketingAlertTime { } public static TicketingAlertTime getAlertTime(LocalDateTime ticketingAt, LocalDateTime alertAt) { - long hoursDifference = Duration.between(alertAt, ticketingAt).toHours(); + long minutesDifference = Duration.between(alertAt, ticketingAt).toMinutes(); return Arrays.stream(TicketingAlertTime.values()) - .filter(alertTime -> alertTime.minutes == hoursDifference) + .filter(alertTime -> alertTime.minutes == minutesDifference) .findFirst() - .orElseThrow(() -> new IllegalArgumentException("일치하지 않은 시간입니다.: " + hoursDifference)); + .orElseThrow(() -> new IllegalArgumentException("일치하지 않은 시간입니다.: " + minutesDifference)); } } diff --git a/app/domain/user-domain/src/testFixtures/java/org/example/fixture/ArtistSubscriptionFixture.java b/app/domain/show-domain/src/testFixtures/java/org/example/fixture/domain/ArtistSubscriptionFixture.java similarity index 82% rename from app/domain/user-domain/src/testFixtures/java/org/example/fixture/ArtistSubscriptionFixture.java rename to app/domain/show-domain/src/testFixtures/java/org/example/fixture/domain/ArtistSubscriptionFixture.java index 2d09b369..8db7f40d 100644 --- a/app/domain/user-domain/src/testFixtures/java/org/example/fixture/ArtistSubscriptionFixture.java +++ b/app/domain/show-domain/src/testFixtures/java/org/example/fixture/domain/ArtistSubscriptionFixture.java @@ -1,9 +1,9 @@ -package org.example.fixture; +package org.example.fixture.domain; import java.util.List; import java.util.UUID; import java.util.stream.IntStream; -import org.example.entity.ArtistSubscription; +import org.example.entity.usershow.ArtistSubscription; public class ArtistSubscriptionFixture { diff --git a/app/domain/user-domain/src/testFixtures/java/org/example/fixture/GenreSubscriptionFixture.java b/app/domain/show-domain/src/testFixtures/java/org/example/fixture/domain/GenreSubscriptionFixture.java similarity index 82% rename from app/domain/user-domain/src/testFixtures/java/org/example/fixture/GenreSubscriptionFixture.java rename to app/domain/show-domain/src/testFixtures/java/org/example/fixture/domain/GenreSubscriptionFixture.java index 2ba5fed4..e5f8cd7e 100644 --- a/app/domain/user-domain/src/testFixtures/java/org/example/fixture/GenreSubscriptionFixture.java +++ b/app/domain/show-domain/src/testFixtures/java/org/example/fixture/domain/GenreSubscriptionFixture.java @@ -1,9 +1,9 @@ -package org.example.fixture; +package org.example.fixture.domain; import java.util.List; import java.util.UUID; import java.util.stream.IntStream; -import org.example.entity.GenreSubscription; +import org.example.entity.usershow.GenreSubscription; public class GenreSubscriptionFixture { diff --git a/app/domain/user-domain/src/main/java/org/example/config/UserDomainConfig.java b/app/domain/user-domain/src/main/java/org/example/config/UserDomainConfig.java index 5711a442..063b42b2 100644 --- a/app/domain/user-domain/src/main/java/org/example/config/UserDomainConfig.java +++ b/app/domain/user-domain/src/main/java/org/example/config/UserDomainConfig.java @@ -10,11 +10,7 @@ @EntityScan(basePackages = "org.example.entity") @EnableJpaRepositories(basePackages = { "org.example.repository.user", - "org.example.repository.admin", - "org.example.repository.subscription", - "org.example.repository.interest", - "org.example.repository.subscription", - "org.example.repository.ticketing" + "org.example.repository.admin" }) public class UserDomainConfig { 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 deleted file mode 100644 index 8e891acc..00000000 --- a/app/domain/user-domain/src/main/java/org/example/repository/interest/InterestShowQuerydslRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -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); -} 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 deleted file mode 100644 index 7737e38b..00000000 --- a/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepository.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.example.repository.ticketing; - -public interface TicketingAlertQuerydslRepository { - -} 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 deleted file mode 100644 index e499a01f..00000000 --- a/app/domain/user-domain/src/main/java/org/example/repository/ticketing/TicketingAlertQuerydslRepositoryImpl.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.example.repository.ticketing; - -import com.querydsl.jpa.impl.JPAQueryFactory; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Repository; - -@Repository -@RequiredArgsConstructor -public class TicketingAlertQuerydslRepositoryImpl implements TicketingAlertQuerydslRepository { - - private final JPAQueryFactory jpaQueryFactory; - -} diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/UserUseCase.java b/app/domain/user-domain/src/main/java/org/example/usecase/UserUseCase.java index b9dafa1d..666f09ed 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/UserUseCase.java +++ b/app/domain/user-domain/src/main/java/org/example/usecase/UserUseCase.java @@ -9,10 +9,6 @@ import org.example.entity.User; import org.example.error.UserError; import org.example.exception.BusinessException; -import org.example.repository.interest.InterestShowRepository; -import org.example.repository.subscription.artistsubscription.ArtistSubscriptionRepository; -import org.example.repository.subscription.genresubscription.GenreSubscriptionRepository; -import org.example.repository.ticketing.TicketingAlertRepository; import org.example.repository.user.SocialLoginRepository; import org.example.repository.user.UserRepository; import org.springframework.stereotype.Component; @@ -24,10 +20,6 @@ public class UserUseCase { private final UserRepository userRepository; private final SocialLoginRepository socialLoginRepository; - private final ArtistSubscriptionRepository artistSubscriptionRepository; - private final GenreSubscriptionRepository genreSubscriptionRepository; - private final InterestShowRepository interestShowRepository; - private final TicketingAlertRepository ticketingAlertRepository; @Transactional public User createNewUser(User user, SocialLogin socialLogin) { @@ -58,11 +50,11 @@ public User findUser(LoginDomainRequest request) { return user; } - @Transactional - public void deleteUser(UUID userId) { + public User deleteUser(UUID userId) { User user = userRepository.findById(userId).orElseThrow(NoSuchElementException::new); userRepository.delete(user); - deleteAssociatedWith(user); + socialLoginRepository.deleteAllByUserId(user.getId()); + return user; } public UserProfileDomainResponse findUserProfile(UUID userId) { @@ -72,12 +64,4 @@ public UserProfileDomainResponse findUserProfile(UUID userId) { public String findUserFcmTokensByUserId(UUID userId) { return userRepository.findUserFcmTokensByUserId(userId).orElseThrow(NoSuchElementException::new); } - - private void deleteAssociatedWith(User user) { - socialLoginRepository.deleteAllByUserId(user.getId()); - artistSubscriptionRepository.deleteAllByUserId(user.getId()); - genreSubscriptionRepository.deleteAllByUserId(user.getId()); - interestShowRepository.deleteAllByUserId(user.getId()); - ticketingAlertRepository.deleteAllByUserId(user.getId()); - } } diff --git a/app/domain/user-domain/src/main/java/org/example/vo/TicketingType.java b/app/domain/user-domain/src/main/java/org/example/vo/TicketingType.java deleted file mode 100644 index 77a9dad1..00000000 --- a/app/domain/user-domain/src/main/java/org/example/vo/TicketingType.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.example.vo; - -public enum TicketingType { - PRE("선예매"), NORMAL("일반예매"), ADDITIONAL("추가예매"); - - TicketingType(String value) { - } -}