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/ArtistService.java b/app/api/show-api/src/main/java/com/example/artist/service/ArtistService.java index 8d59185b..dc10b0cd 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; @@ -22,10 +23,9 @@ import org.example.dto.response.PaginationServiceResponse; import org.example.entity.ArtistSubscription; import org.example.entity.artist.Artist; -import org.example.usecase.ArtistSubscriptionUseCase; -import org.example.usecase.UserShowUseCase; -import org.example.usecase.UserUseCase; import org.example.usecase.artist.ArtistUseCase; +import org.example.usecase.subscription.ArtistSubscriptionUseCase; +import org.example.usecase.user.UserUseCase; 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/GenreService.java b/app/api/show-api/src/main/java/com/example/genre/service/GenreService.java index 2819975b..68047b59 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; @@ -20,9 +21,9 @@ import org.example.dto.response.PaginationServiceResponse; import org.example.entity.GenreSubscription; import org.example.entity.genre.Genre; -import org.example.usecase.GenreSubscriptionUseCase; -import org.example.usecase.UserUseCase; import org.example.usecase.genre.GenreUseCase; +import org.example.usecase.subscription.GenreSubscriptionUseCase; +import org.example.usecase.user.UserUseCase; 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/show/controller/ShowController.java b/app/api/show-api/src/main/java/com/example/show/controller/ShowController.java index 67b04279..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,27 +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.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.example.dto.response.PaginationApiResponse; @@ -33,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 @@ -70,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( @@ -124,59 +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 - ) { - return ResponseEntity.ok( - TicketingAlertReservationApiResponse.from( - showService.findAlertsReservations(user.userId(), showId, type) - ) - ); - } - - @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( @@ -195,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..0984f5b9 --- /dev/null +++ b/app/api/show-api/src/main/java/com/example/show/controller/UserShowController.java @@ -0,0 +1,175 @@ +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 + ) { + return ResponseEntity.ok( + TicketingAlertReservationApiResponse.from( + userShowService.findAlertsReservations(user.userId(), showId, type) + ) + ); + } + + @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/service/ShowService.java b/app/api/show-api/src/main/java/com/example/show/service/ShowService.java index ae8c9435..b44e267c 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,42 +1,18 @@ 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.TicketingAlertReservationAvailabilityServiceResponse; -import com.example.show.service.dto.response.TicketingAlertReservationServiceResponse; -import com.example.show.service.dto.response.TicketingAlertReservationStatusServiceResponse; 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.interest.InterestShowUseCase; import org.example.usecase.show.ShowUseCase; import org.springframework.stereotype.Service; @@ -45,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); @@ -92,115 +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 - ) { - var ticketingAt = showUseCase - .findTicketingAlertReservation(showId, type.toDomainType()) - .getTicketingAt(); - - var reservedAlerts = ticketingAlertUseCase.findTicketingAlerts(userId, showId) - .stream() - .map(TicketingAlert::getAlertTime) - .toList(); - - var status = TicketingAlertReservationStatusServiceResponse.as( - reservedAlerts, - ticketingAt - ); - var availability = TicketingAlertReservationAvailabilityServiceResponse.as(ticketingAt); - - return TicketingAlertReservationServiceResponse.as(status, availability); - } - - 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..ca94406c --- /dev/null +++ b/app/api/show-api/src/main/java/com/example/show/service/UserShowService.java @@ -0,0 +1,169 @@ +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.TicketingAlertReservationAvailabilityServiceResponse; +import com.example.show.service.dto.response.TicketingAlertReservationServiceResponse; +import com.example.show.service.dto.response.TicketingAlertReservationStatusServiceResponse; +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.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.interest.InterestShowUseCase; +import org.example.usecase.show.ShowUseCase; +import org.example.usecase.ticketing.TicketingAlertUseCase; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class UserShowService { + + private final ShowUseCase showUseCase; + 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 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 TicketingAlertReservationServiceResponse findAlertsReservations( + UUID userId, + UUID showId, + TicketingApiType type + ) { + var ticketingAt = showUseCase + .findTicketingAlertReservation(showId, type.toDomainType()) + .getTicketingAt(); + + var reservedAlerts = ticketingAlertUseCase.findTicketingAlerts(userId, showId) + .stream() + .map(TicketingAlert::getAlertTime) + .toList(); + + var status = TicketingAlertReservationStatusServiceResponse.as( + reservedAlerts, + ticketingAt + ); + var availability = TicketingAlertReservationAvailabilityServiceResponse.as(ticketingAt); + + return TicketingAlertReservationServiceResponse.as(status, availability); + } + + public NumberOfTicketingAlertServiceResponse countAlertShows(UUID userId, LocalDateTime now) { + long numberOfTicketingAlert = interestShowUseCase.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/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/ArtistServiceTest.java b/app/api/show-api/src/test/java/artist/service/ArtistServiceTest.java index b4a5b2d9..3c0369be 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 @@ -23,10 +23,9 @@ import org.example.entity.artist.Artist; import org.example.fixture.ArtistSubscriptionFixture; import org.example.fixture.domain.ArtistFixture; -import org.example.usecase.ArtistSubscriptionUseCase; -import org.example.usecase.UserShowUseCase; -import org.example.usecase.UserUseCase; import org.example.usecase.artist.ArtistUseCase; +import org.example.usecase.subscription.ArtistSubscriptionUseCase; +import org.example.usecase.user.UserUseCase; 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..18f4a142 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 @@ -22,9 +22,9 @@ import org.example.entity.genre.Genre; import org.example.fixture.GenreSubscriptionFixture; import org.example.fixture.domain.GenreFixture; -import org.example.usecase.GenreSubscriptionUseCase; -import org.example.usecase.UserUseCase; import org.example.usecase.genre.GenreUseCase; +import org.example.usecase.subscription.GenreSubscriptionUseCase; +import org.example.usecase.user.UserUseCase; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; 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..2b931818 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,12 +7,10 @@ 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.interest.InterestShowUseCase; import org.example.usecase.show.ShowUseCase; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -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/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/AdminService.java b/app/api/user-api/src/main/java/org/example/service/AdminService.java index 60f75d66..cae95ab2 100644 --- a/app/api/user-api/src/main/java/org/example/service/AdminService.java +++ b/app/api/user-api/src/main/java/org/example/service/AdminService.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import org.example.service.dto.request.AdminLoginServiceRequest; -import org.example.usecase.AdminUseCase; +import org.example.usecase.admin.AdminUseCase; import org.springframework.stereotype.Service; @Service 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..2ac878e6 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,7 +16,7 @@ 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.UserUseCase; +import org.example.usecase.user.UserUseCase; import org.springframework.stereotype.Service; @Service 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..1d14e7a8 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,7 +15,7 @@ import org.example.security.dto.UserParam; import org.example.security.token.JWTGenerator; import org.example.security.token.TokenProcessor; -import org.example.usecase.UserUseCase; +import org.example.usecase.user.UserUseCase; import org.example.vo.SocialLoginApiType; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/AdminUseCase.java b/app/domain/user-domain/src/main/java/org/example/usecase/admin/AdminUseCase.java similarity index 95% rename from app/domain/user-domain/src/main/java/org/example/usecase/AdminUseCase.java rename to app/domain/user-domain/src/main/java/org/example/usecase/admin/AdminUseCase.java index 8dfe79cc..f435ba71 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/AdminUseCase.java +++ b/app/domain/user-domain/src/main/java/org/example/usecase/admin/AdminUseCase.java @@ -1,4 +1,4 @@ -package org.example.usecase; +package org.example.usecase.admin; import lombok.RequiredArgsConstructor; import org.example.entity.Admin; diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/UserShowUseCase.java b/app/domain/user-domain/src/main/java/org/example/usecase/interest/InterestShowUseCase.java similarity index 66% rename from app/domain/user-domain/src/main/java/org/example/usecase/UserShowUseCase.java rename to app/domain/user-domain/src/main/java/org/example/usecase/interest/InterestShowUseCase.java index 7f600e91..ade1a755 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/UserShowUseCase.java +++ b/app/domain/user-domain/src/main/java/org/example/usecase/interest/InterestShowUseCase.java @@ -1,28 +1,22 @@ -package org.example.usecase; +package org.example.usecase.interest; 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.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) { @@ -47,11 +41,8 @@ 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); } @@ -59,16 +50,6 @@ 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; diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/ArtistSubscriptionUseCase.java b/app/domain/user-domain/src/main/java/org/example/usecase/subscription/ArtistSubscriptionUseCase.java similarity index 84% rename from app/domain/user-domain/src/main/java/org/example/usecase/ArtistSubscriptionUseCase.java rename to app/domain/user-domain/src/main/java/org/example/usecase/subscription/ArtistSubscriptionUseCase.java index b2c3a3d2..980f1ce8 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/ArtistSubscriptionUseCase.java +++ b/app/domain/user-domain/src/main/java/org/example/usecase/subscription/ArtistSubscriptionUseCase.java @@ -1,4 +1,4 @@ -package org.example.usecase; +package org.example.usecase.subscription; import java.util.ArrayList; import java.util.List; @@ -59,4 +59,14 @@ 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; + } } diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/GenreSubscriptionUseCase.java b/app/domain/user-domain/src/main/java/org/example/usecase/subscription/GenreSubscriptionUseCase.java similarity index 90% rename from app/domain/user-domain/src/main/java/org/example/usecase/GenreSubscriptionUseCase.java rename to app/domain/user-domain/src/main/java/org/example/usecase/subscription/GenreSubscriptionUseCase.java index ea840696..2a7fdb3a 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/GenreSubscriptionUseCase.java +++ b/app/domain/user-domain/src/main/java/org/example/usecase/subscription/GenreSubscriptionUseCase.java @@ -1,4 +1,4 @@ -package org.example.usecase; +package org.example.usecase.subscription; import java.util.ArrayList; import java.util.List; @@ -59,4 +59,9 @@ public List unsubscribe(List genreIds, UUID userId) { return filteredSubscriptions; } + + public long countSubscribedGenres(UUID userId) { + Long result = genreSubscriptionRepository.countByUserIdAndIsDeletedFalse(userId); + return result == null ? 0 : result; + } } diff --git a/app/domain/user-domain/src/main/java/org/example/usecase/TicketingAlertUseCase.java b/app/domain/user-domain/src/main/java/org/example/usecase/ticketing/TicketingAlertUseCase.java similarity index 99% rename from app/domain/user-domain/src/main/java/org/example/usecase/TicketingAlertUseCase.java rename to app/domain/user-domain/src/main/java/org/example/usecase/ticketing/TicketingAlertUseCase.java index 62b429d9..e2be7f5d 100644 --- a/app/domain/user-domain/src/main/java/org/example/usecase/TicketingAlertUseCase.java +++ b/app/domain/user-domain/src/main/java/org/example/usecase/ticketing/TicketingAlertUseCase.java @@ -1,4 +1,4 @@ -package org.example.usecase; +package org.example.usecase.ticketing; import java.time.LocalDateTime; import java.util.List; 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/user/UserUseCase.java similarity index 98% rename from app/domain/user-domain/src/main/java/org/example/usecase/UserUseCase.java rename to app/domain/user-domain/src/main/java/org/example/usecase/user/UserUseCase.java index b9dafa1d..9ef0727f 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/user/UserUseCase.java @@ -1,4 +1,4 @@ -package org.example.usecase; +package org.example.usecase.user; import java.util.NoSuchElementException; import java.util.UUID;