Skip to content

Commit

Permalink
fix: UserShowController 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
GaBaljaintheroom committed Sep 12, 2024
1 parent 604a8cc commit 0dffe24
Show file tree
Hide file tree
Showing 34 changed files with 493 additions and 486 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,6 +84,18 @@ public ResponseEntity<PaginationApiResponse<ArtistSubscriptionPaginationApiParam
);
}

@GetMapping("/subscriptions/count")
@Operation(summary = "구독한 아티스트 수")
public ResponseEntity<NumberOfSubscribedArtistApiResponse> getNumberOfSubscribedArtist(
@AuthenticationPrincipal AuthenticatedUser user
) {
return ResponseEntity.ok(
NumberOfSubscribedArtistApiResponse.from(
artistService.countSubscribedArtists(user.userId())
)
);
}

@PostMapping("/subscribe")
@Operation(summary = "구독하기")
public ResponseEntity<ArtistSubscriptionApiResponse> subscribe(
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;

Expand All @@ -46,7 +45,7 @@ public PaginationServiceResponse<ArtistSearchPaginationServiceParam> searchArtis

List<UUID> subscribedArtistIds = request.userId() == null
? List.of()
: userShowUseCase.findArtistSubscriptionByUserId(request.userId()).stream()
: artistSubscriptionUseCase.findArtistSubscriptionByUserId(request.userId()).stream()
.map(ArtistSubscription::getArtistId)
.toList();

Expand Down Expand Up @@ -123,7 +122,6 @@ public ArtistUnsubscriptionServiceResponse unsubscribe(
.map(ArtistServiceMessage::toUnsubscribe)
.toList();


var userFcmToken = userUseCase.findUserFcmTokensByUserId(request.userId());

messagePublisher.publishArtistSubscription(
Expand Down Expand Up @@ -191,6 +189,12 @@ public PaginationServiceResponse<ArtistUnsubscriptionPaginationServiceParam> fin
return PaginationServiceResponse.of(data, response.hasNext());
}

public NumberOfSubscribedArtistServiceResponse countSubscribedArtists(UUID userId) {
return NumberOfSubscribedArtistServiceResponse.from(
artistSubscriptionUseCase.countSubscribedArtists(userId)
);
}

private List<UUID> getSubscriptionArtistIds(UUID userId) {
List<ArtistSubscription> subscriptions = artistSubscriptionUseCase.findSubscriptionList(
userId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.example.service.dto.response;
package com.example.artist.service.dto.response;

public record NumberOfSubscribedArtistServiceResponse(
long count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -92,6 +93,18 @@ public ResponseEntity<PaginationApiResponse<GenreSubscriptionPaginationApiParam>
);
}

@GetMapping("/subscriptions/count")
@Operation(summary = "구독한 장르 수")
public ResponseEntity<NumberOfSubscribedGenreApiResponse> getNumberOfSubscribedGenre(
@AuthenticationPrincipal AuthenticatedUser user
) {
return ResponseEntity.ok(
NumberOfSubscribedGenreApiResponse.from(
genreService.countSubscribedGenres(user.userId())
)
);
}

@PostMapping("/subscribe")
@Operation(summary = "구독하기")
public ResponseEntity<GenreSubscriptionApiResponse> subscribe(
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -100,7 +101,9 @@ public GenreUnsubscriptionServiceResponse unsubscribe(
.build();
}

public PaginationServiceResponse<GenrePaginationServiceParam> findGenres(GenrePaginationServiceRequest request) {
public PaginationServiceResponse<GenrePaginationServiceParam> findGenres(
GenrePaginationServiceRequest request
) {
List<UUID> subscriptionGenreIds = request.userId() == null
? List.of()
: getSubscriptionGenreIds(request.userId());
Expand Down Expand Up @@ -146,6 +149,12 @@ public PaginationServiceResponse<GenreUnsubscriptionPaginationServiceParam> find
return PaginationServiceResponse.of(data, response.hasNext());
}

public NumberOfSubscribedGenreServiceResponse countSubscribedGenres(UUID uuid) {
return NumberOfSubscribedGenreServiceResponse.from(
genreSubscriptionUseCase.countSubscribedGenres(uuid)
);
}

private List<UUID> getSubscriptionGenreIds(UUID userId) {
List<GenreSubscription> subscriptions = genreSubscriptionUseCase.findSubscriptions(userId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.example.service.dto.response;
package com.example.genre.service.dto.response;

public record NumberOfSubscribedGenreServiceResponse(
long count
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -70,46 +54,6 @@ public ResponseEntity<PaginationApiResponse<ShowPaginationApiParam>> getShows(

}

@PostMapping("/{showId}/interests")
@Operation(summary = "공연 관심 등록 / 취소")
public ResponseEntity<ShowInterestApiResponse> 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<PaginationApiResponse<InterestShowPaginationApiResponse>> getInterests(
@ParameterObject ShowInterestPaginationApiRequest request,
@AuthenticationPrincipal AuthenticatedUser user
) {
var serviceResponse = showService.findInterestShows(
request.toServiceRequest(user.userId())
);

List<InterestShowPaginationApiResponse> response = serviceResponse.data().stream()
.map(InterestShowPaginationApiResponse::from)
.toList();

return ResponseEntity.ok(
PaginationApiResponse.<InterestShowPaginationApiResponse>builder()
.data(response)
.hasNext(serviceResponse.hasNext())
.build()
);
}

@GetMapping("/{showId}")
@Operation(summary = "공연 상세 조회")
public ResponseEntity<ShowDetailApiResponse> getShow(
Expand All @@ -124,59 +68,6 @@ public ResponseEntity<ShowDetailApiResponse> getShow(
);
}

@GetMapping("/{showId}/alert/reservations")
@Operation(summary = "공연 티켓팅 알림 예약 조회")
public ResponseEntity<TicketingAlertReservationApiResponse> 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<Void> 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<PaginationApiResponse<ShowAlertPaginationApiParam>> getAlerts(
@AuthenticationPrincipal AuthenticatedUser user,
@ParameterObject ShowAlertPaginationApiRequest request
) {
PaginationServiceResponse<ShowAlertPaginationServiceParam> alertShows = showService.findAlertShows(
request.toServiceRequest(user.userId()));

var showAlertPaginationApiParams = alertShows.data().stream()
.map(ShowAlertPaginationApiParam::from)
.toList();

return ResponseEntity.ok(
PaginationApiResponse.<ShowAlertPaginationApiParam>builder()
.data(showAlertPaginationApiParams)
.hasNext(alertShows.hasNext())
.build()
);
}

@GetMapping("/search")
@Operation(summary = "검색하기")
public ResponseEntity<PaginationApiResponse<ShowSearchPaginationApiParam>> search(
Expand All @@ -195,16 +86,4 @@ public ResponseEntity<PaginationApiResponse<ShowSearchPaginationApiParam>> searc
.build()
);
}

@GetMapping("/terminated/ticketing/count")
@Operation(summary = "티켓팅 알림 설정 후 공연이 종료된 개수")
public ResponseEntity<TerminatedTicketingShowCountApiResponse> getNumberOfTerminatedTicketingShowCount(
@AuthenticationPrincipal AuthenticatedUser user
) {
return ResponseEntity.ok(
TerminatedTicketingShowCountApiResponse.from(
showService.countTerminatedTicketingShow(user.userId())
)
);
}
}
Loading

0 comments on commit 0dffe24

Please sign in to comment.