Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : user-show 관심사 이동 #159

Merged
merged 9 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/showpot-dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- develop
- temp-develop

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions app/api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
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 @@ -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
Expand Down
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 @@ -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
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 @@ -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
Expand Down
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 @@ -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
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
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -14,11 +14,12 @@ public record TicketingAlertsToReserveServiceMessage(
List<TicketingTimeServiceMessage> 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading
Loading