From 148b92743202cd39855f76612385e686e368f62f Mon Sep 17 00:00:00 2001 From: JunsuPark Date: Sun, 15 Sep 2024 22:48:07 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=ED=97=A4=EB=8D=94=20=EA=B0=92=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EC=88=98=EC=A0=95=20(#161)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/example/filter/JWTFilter.java | 37 ++++++++++---- .../example/repository/TokenRepository.java | 2 +- .../security/dto/AuthenticatedInfo.java | 36 +++++++++++++ .../security/dto/AuthenticatedUser.java | 13 ----- .../security/token/TokenProcessor.java | 5 +- .../java/org/example/util/ValidatorUser.java | 4 +- .../artist/controller/ArtistController.java | 42 +++++++--------- .../ArtistSearchPaginationApiRequest.java | 8 +-- ...istUnsubscriptionPaginationApiRequest.java | 13 ----- .../dto/response/ArtistSearchApiResponse.java | 29 ----------- .../dto/response/ArtistSimpleApiResponse.java | 18 ------- .../example/artist/service/ArtistService.java | 19 ++----- ...nsubscriptionPaginationServiceRequest.java | 8 --- ...stKoreanNameWithShowIdServiceResponse.java | 27 ---------- .../response/ArtistSearchServiceResponse.java | 21 -------- ...SubscriptionPaginationServiceResponse.java | 13 ----- ...subscriptionPaginationServiceResponse.java | 13 ----- .../example/component/ViewCountComponent.java | 2 +- .../genre/controller/GenreController.java | 29 ++++++----- .../request/GenrePaginationApiRequest.java | 5 +- .../response/GenrePaginationApiResponse.java | 15 ------ .../dto/response/GenreSimpleApiResponse.java | 18 ------- .../GenreNameWithShowIdServiceResponse.java | 23 --------- ...SubscriptionPaginationServiceResponse.java | 13 ----- .../show/controller/ShowController.java | 10 ++-- .../show/controller/UserShowController.java | 34 ++++++------- .../ShowAlertPaginationApiResponse.java | 17 ------- .../ShowArtistPaginationApiParam.java | 23 --------- .../response/ShowArtistSimpleApiResponse.java | 14 ------ .../response/ShowGenrePaginationApiParam.java | 19 ------- .../response/ShowGenreSimpleApiResponse.java | 8 --- .../dto/response/ShowSimpleApiResponse.java | 35 ------------- .../ShowTicketingTimePaginationApiParam.java | 20 -------- ...ShowWithTicketingTimesServiceResponse.java | 50 ------------------- .../TicketingAndShowInfoApiResponse.java | 17 ------- .../com/example/show/service/ShowService.java | 4 +- .../artist/service/ArtistServiceTest.java | 5 +- .../example/controller/UserController.java | 23 ++++----- .../dto/request/LogoutApiRequest.java | 20 -------- .../dto/request/ReissueApiRequest.java | 16 ------ .../dto/request/WithdrawalApiRequest.java | 21 -------- .../java/org/example/service/UserService.java | 23 ++++----- .../dto/request/LogoutServiceRequest.java | 12 ----- .../dto/request/ReissueServiceRequest.java | 7 --- .../dto/request/WithdrawalServiceRequest.java | 12 ----- .../artist/response/ArtistSearchResponse.java | 12 ----- .../ShowPaginationDomainResponse.java | 12 ----- .../java/org/example/usecase/UserUseCase.java | 9 ++-- .../repository/RedisTokenRepository.java | 9 +++- .../repository/RedisViewCountComponent.java | 6 +-- 50 files changed, 176 insertions(+), 675 deletions(-) create mode 100644 app/api/common-api/src/main/java/org/example/security/dto/AuthenticatedInfo.java delete mode 100644 app/api/common-api/src/main/java/org/example/security/dto/AuthenticatedUser.java delete mode 100644 app/api/show-api/src/main/java/com/example/artist/controller/dto/response/ArtistSearchApiResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/artist/controller/dto/response/ArtistSimpleApiResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistKoreanNameWithShowIdServiceResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistSearchServiceResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistSubscriptionPaginationServiceResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistUnsubscriptionPaginationServiceResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/genre/controller/dto/response/GenrePaginationApiResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/genre/controller/dto/response/GenreSimpleApiResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/genre/service/dto/response/GenreNameWithShowIdServiceResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/genre/service/dto/response/GenreSubscriptionPaginationServiceResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowAlertPaginationApiResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowArtistPaginationApiParam.java delete mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowArtistSimpleApiResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowGenrePaginationApiParam.java delete mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowGenreSimpleApiResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowSimpleApiResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowTicketingTimePaginationApiParam.java delete mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowWithTicketingTimesServiceResponse.java delete mode 100644 app/api/show-api/src/main/java/com/example/show/controller/dto/response/TicketingAndShowInfoApiResponse.java delete mode 100644 app/api/user-api/src/main/java/org/example/controller/dto/request/LogoutApiRequest.java delete mode 100644 app/api/user-api/src/main/java/org/example/controller/dto/request/ReissueApiRequest.java delete mode 100644 app/api/user-api/src/main/java/org/example/controller/dto/request/WithdrawalApiRequest.java delete mode 100644 app/api/user-api/src/main/java/org/example/service/dto/request/LogoutServiceRequest.java delete mode 100644 app/api/user-api/src/main/java/org/example/service/dto/request/ReissueServiceRequest.java delete mode 100644 app/api/user-api/src/main/java/org/example/service/dto/request/WithdrawalServiceRequest.java delete mode 100644 app/domain/show-domain/src/main/java/org/example/dto/artist/response/ArtistSearchResponse.java delete mode 100644 app/domain/show-domain/src/main/java/org/example/dto/show/response/ShowPaginationDomainResponse.java diff --git a/app/api/common-api/src/main/java/org/example/filter/JWTFilter.java b/app/api/common-api/src/main/java/org/example/filter/JWTFilter.java index 93b9e0f7..761e70f1 100644 --- a/app/api/common-api/src/main/java/org/example/filter/JWTFilter.java +++ b/app/api/common-api/src/main/java/org/example/filter/JWTFilter.java @@ -7,7 +7,7 @@ import java.io.IOException; import java.util.List; import lombok.RequiredArgsConstructor; -import org.example.security.dto.AuthenticatedUser; +import org.example.security.dto.AuthenticatedInfo; import org.example.security.dto.UserParam; import org.example.security.token.JWTHandler; import org.example.security.token.TokenProcessor; @@ -34,6 +34,10 @@ protected void doFilterInternal( handleAccessToken(request); } + if (request.getHeader("Refresh") != null) { + handleRefreshToken(request); + } + filterChain.doFilter(request, response); } @@ -41,20 +45,35 @@ private void handleAccessToken(HttpServletRequest request) { String accessToken = jwtHandler.extractAccessToken(request); UserParam userParam = jwtHandler.extractUserFrom(accessToken); tokenProcessor.verifyAccessTokenBlacklist(userParam, accessToken); - saveOnSecurityContextHolder(userParam); + saveOnSecurityContextHolder(userParam, accessToken); + } + + private void saveOnSecurityContextHolder(UserParam userParam, String accessToken) { + var authenticatedInfo = AuthenticatedInfo.getUserWithAccessToken(userParam, accessToken); + + SecurityContextHolder.getContext().setAuthentication( + new UsernamePasswordAuthenticationToken( + authenticatedInfo, + null, + List.of(new SimpleGrantedAuthority(authenticatedInfo.role().getAuthority())) + ) + ); + } + + private void handleRefreshToken(HttpServletRequest request) { + String refreshToken = jwtHandler.extractRefreshToken(request); + UserParam userParam = jwtHandler.extractUserFrom(refreshToken); + saveOnSecurityContextHolderWithRefreshToken(userParam, refreshToken); } - private void saveOnSecurityContextHolder(UserParam userParam) { - AuthenticatedUser authenticatedUser = AuthenticatedUser.builder() - .userId(userParam.userId()) - .role(userParam.role()) - .build(); + private void saveOnSecurityContextHolderWithRefreshToken(UserParam userParam, String refreshToken) { + var authenticatedInfo = AuthenticatedInfo.getUserWithRefreshToken(userParam, refreshToken); SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken( - authenticatedUser, + authenticatedInfo, null, - List.of(new SimpleGrantedAuthority(authenticatedUser.role().getAuthority())) + List.of(new SimpleGrantedAuthority(authenticatedInfo.role().getAuthority())) ) ); } diff --git a/app/api/common-api/src/main/java/org/example/repository/TokenRepository.java b/app/api/common-api/src/main/java/org/example/repository/TokenRepository.java index 49e12493..a400a385 100644 --- a/app/api/common-api/src/main/java/org/example/repository/TokenRepository.java +++ b/app/api/common-api/src/main/java/org/example/repository/TokenRepository.java @@ -15,5 +15,5 @@ public interface TokenRepository { boolean existAccessTokenInBlacklist(UUID userId, String accessToken); - void deleteRefreshToken(UUID userId); + boolean deleteRefreshToken(UUID userId); } diff --git a/app/api/common-api/src/main/java/org/example/security/dto/AuthenticatedInfo.java b/app/api/common-api/src/main/java/org/example/security/dto/AuthenticatedInfo.java new file mode 100644 index 00000000..67f4d00f --- /dev/null +++ b/app/api/common-api/src/main/java/org/example/security/dto/AuthenticatedInfo.java @@ -0,0 +1,36 @@ +package org.example.security.dto; + +import java.util.UUID; +import lombok.Builder; +import org.example.vo.UserRoleApiType; + +@Builder +public record AuthenticatedInfo( + String accessToken, + String refreshToken, + UUID userId, + UserRoleApiType role +) { + + public static AuthenticatedInfo getUserWithAccessToken( + UserParam userParam, + String accessToken + ) { + return AuthenticatedInfo.builder() + .userId(userParam.userId()) + .role(userParam.role()) + .accessToken(accessToken) + .build(); + } + + public static AuthenticatedInfo getUserWithRefreshToken( + UserParam userParam, + String refreshToken + ) { + return AuthenticatedInfo.builder() + .refreshToken(refreshToken) + .userId(userParam.userId()) + .role(userParam.role()) + .build(); + } +} diff --git a/app/api/common-api/src/main/java/org/example/security/dto/AuthenticatedUser.java b/app/api/common-api/src/main/java/org/example/security/dto/AuthenticatedUser.java deleted file mode 100644 index cd1c2ab5..00000000 --- a/app/api/common-api/src/main/java/org/example/security/dto/AuthenticatedUser.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.example.security.dto; - -import java.util.UUID; -import lombok.Builder; -import org.example.vo.UserRoleApiType; - -@Builder -public record AuthenticatedUser( - UUID userId, - UserRoleApiType role -) { - -} diff --git a/app/api/common-api/src/main/java/org/example/security/token/TokenProcessor.java b/app/api/common-api/src/main/java/org/example/security/token/TokenProcessor.java index 447d4d97..a8695629 100644 --- a/app/api/common-api/src/main/java/org/example/security/token/TokenProcessor.java +++ b/app/api/common-api/src/main/java/org/example/security/token/TokenProcessor.java @@ -40,7 +40,10 @@ public void makeAccessTokenBlacklistAndDeleteRefreshToken( UUID userId ) { tokenRepository.saveBlacklistAccessToken(userId, accessToken); - tokenRepository.deleteRefreshToken(userId); + + if (!tokenRepository.deleteRefreshToken(userId)) { + throw new BusinessException(TokenError.INVALID_TOKEN); + } } private String getExistRefreshToken(UserParam userParam) { diff --git a/app/api/common-api/src/main/java/org/example/util/ValidatorUser.java b/app/api/common-api/src/main/java/org/example/util/ValidatorUser.java index 4e8c1a16..0a2c15da 100644 --- a/app/api/common-api/src/main/java/org/example/util/ValidatorUser.java +++ b/app/api/common-api/src/main/java/org/example/util/ValidatorUser.java @@ -1,11 +1,11 @@ package org.example.util; import java.util.UUID; -import org.example.security.dto.AuthenticatedUser; +import org.example.security.dto.AuthenticatedInfo; public final class ValidatorUser { - public static UUID getUserId(AuthenticatedUser user) { + public static UUID getUserId(AuthenticatedInfo user) { if (user == null) { return null; } 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 f0bbe599..7475f3e9 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 @@ -17,9 +17,11 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.util.UUID; import lombok.RequiredArgsConstructor; import org.example.dto.response.PaginationApiResponse; -import org.example.security.dto.AuthenticatedUser; +import org.example.security.dto.AuthenticatedInfo; +import org.example.util.ValidatorUser; import org.springdoc.core.annotations.ParameterObject; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -40,18 +42,11 @@ public class ArtistController { @GetMapping("/unsubscriptions") @Operation(summary = "구독하지 않은 아티스트 목록 조회") public ResponseEntity> getUnsubscribedArtists( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @ParameterObject ArtistUnsubscriptionPaginationApiRequest request ) { - var response = - (user == null) - ? artistService.findArtistUnsubscriptionsForNonUser( - request.toNonUserServiceRequest() - ) - : artistService.findArtistUnsubscriptions( - request.toServiceRequest(user.userId()) - ); - + UUID userId = ValidatorUser.getUserId(info); + var response = artistService.findArtistUnsubscriptions(request.toServiceRequest(userId)); var data = response.data().stream() .map(ArtistUnsubscriptionPaginationApiParam::from) .toList(); @@ -67,11 +62,11 @@ public ResponseEntity> getSubscribedArtists( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @ParameterObject ArtistSubscriptionPaginationApiRequest request ) { var response = artistService.findArtistSubscriptions( - request.toServiceRequest(user.userId())); + request.toServiceRequest(info.userId())); var data = response.data().stream() .map(ArtistSubscriptionPaginationApiParam::from) .toList(); @@ -87,11 +82,11 @@ public ResponseEntity getNumberOfSubscribedArtist( - @AuthenticationPrincipal AuthenticatedUser user + @AuthenticationPrincipal AuthenticatedInfo info ) { return ResponseEntity.ok( NumberOfSubscribedArtistApiResponse.from( - artistService.countSubscribedArtists(user.userId()) + artistService.countSubscribedArtists(info.userId()) ) ); } @@ -99,12 +94,12 @@ public ResponseEntity getNumberOfSubscribed @PostMapping("/subscribe") @Operation(summary = "구독하기") public ResponseEntity subscribe( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @Valid @RequestBody ArtistSubscriptionApiRequest request ) { return ResponseEntity.ok( ArtistSubscriptionApiResponse.from( - artistService.subscribe(request.toServiceRequest(user.userId())) + artistService.subscribe(request.toServiceRequest(info.userId())) ) ); } @@ -112,12 +107,12 @@ public ResponseEntity subscribe( @PostMapping("/unsubscribe") @Operation(summary = "구독 취소하기") public ResponseEntity unsubscribe( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @Valid @RequestBody ArtistUnsubscriptionApiRequest request ) { return ResponseEntity.ok( ArtistUnsubscriptionApiResponse.from( - artistService.unsubscribe(request.toServiceRequest(user.userId())) + artistService.unsubscribe(request.toServiceRequest(info.userId())) ) ); } @@ -125,10 +120,11 @@ public ResponseEntity unsubscribe( @GetMapping("/search") @Operation(summary = "검색하기") public ResponseEntity> search( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @ParameterObject ArtistSearchPaginationApiRequest request ) { - var response = artistService.searchArtist(request.toServiceRequest(user)); + UUID userId = ValidatorUser.getUserId(info); + var response = artistService.searchArtist(request.toServiceRequest(userId)); var data = response.data().stream() .map(ArtistSearchPaginationApiParam::from) .toList(); @@ -144,11 +140,11 @@ public ResponseEntity> sea @GetMapping("/filter-total-count") @Operation(summary = "필터링한 데이터의 총 개수 가져오기") public ResponseEntity filterTotalCount( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @Valid @RequestBody ArtistFilterTotalCountApiRequest request ) { var response = artistService.filterArtistTotalCount( - request.toServiceRequest(user.userId())); + request.toServiceRequest(info.userId())); return ResponseEntity.ok( ArtistFilterTotalCountApiResponse.from(response.totalCount()) diff --git a/app/api/show-api/src/main/java/com/example/artist/controller/dto/request/ArtistSearchPaginationApiRequest.java b/app/api/show-api/src/main/java/com/example/artist/controller/dto/request/ArtistSearchPaginationApiRequest.java index c632dd20..67af38cb 100644 --- a/app/api/show-api/src/main/java/com/example/artist/controller/dto/request/ArtistSearchPaginationApiRequest.java +++ b/app/api/show-api/src/main/java/com/example/artist/controller/dto/request/ArtistSearchPaginationApiRequest.java @@ -5,7 +5,6 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import java.util.UUID; -import org.example.security.dto.AuthenticatedUser; public record ArtistSearchPaginationApiRequest( @@ -31,12 +30,7 @@ public record ArtistSearchPaginationApiRequest( } } - public ArtistSearchPaginationServiceRequest toServiceRequest(AuthenticatedUser user) { - UUID userId = null; - if (user != null) { - userId = user.userId(); - } - + public ArtistSearchPaginationServiceRequest toServiceRequest(UUID userId) { return ArtistSearchPaginationServiceRequest.builder() .userId(userId) .sortStandard(sortStandard) diff --git a/app/api/show-api/src/main/java/com/example/artist/controller/dto/request/ArtistUnsubscriptionPaginationApiRequest.java b/app/api/show-api/src/main/java/com/example/artist/controller/dto/request/ArtistUnsubscriptionPaginationApiRequest.java index df75d182..d2cdd444 100644 --- a/app/api/show-api/src/main/java/com/example/artist/controller/dto/request/ArtistUnsubscriptionPaginationApiRequest.java +++ b/app/api/show-api/src/main/java/com/example/artist/controller/dto/request/ArtistUnsubscriptionPaginationApiRequest.java @@ -65,17 +65,4 @@ public ArtistUnsubscriptionPaginationServiceRequest toServiceRequest(UUID userId .size(size) .build(); } - - public ArtistUnsubscriptionPaginationServiceRequest toNonUserServiceRequest() { - return ArtistUnsubscriptionPaginationServiceRequest.builder() - .subscriptionStatusApiType(SubscriptionStatusApiType.UNSUBSCRIBED) - .sortStandard(sortStandard) - .artistGenderApiTypes(artistGenderApiTypes) - .artistApiTypes(artistApiTypes) - .genreIds(genreIds) - .userId(null) - .cursor(cursor) - .size(size) - .build(); - } } diff --git a/app/api/show-api/src/main/java/com/example/artist/controller/dto/response/ArtistSearchApiResponse.java b/app/api/show-api/src/main/java/com/example/artist/controller/dto/response/ArtistSearchApiResponse.java deleted file mode 100644 index 3184104e..00000000 --- a/app/api/show-api/src/main/java/com/example/artist/controller/dto/response/ArtistSearchApiResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.example.artist.controller.dto.response; - -import com.example.artist.service.dto.response.ArtistSearchServiceResponse; -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.UUID; - -public record ArtistSearchApiResponse( - @Schema(description = "아티스트 ID") - UUID id, - - @Schema(description = "아티스트 한국 이름") - String koreanName, - - @Schema(description = "아티스트 영어 이름") - String englishName, - - @Schema(description = "아티스트 이미지") - String image -) { - - public ArtistSearchApiResponse(ArtistSearchServiceResponse artistSearchServiceResponse) { - this( - artistSearchServiceResponse.id(), - artistSearchServiceResponse.koreanName(), - artistSearchServiceResponse.englishName(), - artistSearchServiceResponse.image() - ); - } -} diff --git a/app/api/show-api/src/main/java/com/example/artist/controller/dto/response/ArtistSimpleApiResponse.java b/app/api/show-api/src/main/java/com/example/artist/controller/dto/response/ArtistSimpleApiResponse.java deleted file mode 100644 index b5282330..00000000 --- a/app/api/show-api/src/main/java/com/example/artist/controller/dto/response/ArtistSimpleApiResponse.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.example.artist.controller.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.UUID; - -public record ArtistSimpleApiResponse( - - @Schema(description = "아티스트 ID") - UUID id, - - @Schema(description = "아티스트 이름") - String name, - - @Schema(description = "아티스트 이미지 주소") - String image -) { - -} 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 3046abc8..f6159c4d 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 @@ -166,7 +166,9 @@ public PaginationServiceResponse findA public PaginationServiceResponse findArtistUnsubscriptions( ArtistUnsubscriptionPaginationServiceRequest request ) { - List subscriptionArtistIds = getSubscriptionArtistIds(request.userId()); + List subscriptionArtistIds = request.userId() == null + ? List.of() + : getSubscriptionArtistIds(request.userId()); var response = artistUseCase.findAllArtistInCursorPagination( request.toDomainRequest(subscriptionArtistIds)); @@ -177,18 +179,6 @@ public PaginationServiceResponse fin return PaginationServiceResponse.of(data, response.hasNext()); } - public PaginationServiceResponse findArtistUnsubscriptionsForNonUser( - ArtistUnsubscriptionPaginationServiceRequest request - ) { - var response = artistUseCase.findAllArtistInCursorPagination( - request.toNonUserDomainRequest()); - List data = response.data().stream() - .map(ArtistUnsubscriptionPaginationServiceParam::new) - .toList(); - - return PaginationServiceResponse.of(data, response.hasNext()); - } - public NumberOfSubscribedArtistServiceResponse countSubscribedArtists(UUID userId) { return NumberOfSubscribedArtistServiceResponse.from( artistSubscriptionUseCase.countSubscribedArtists(userId) @@ -196,8 +186,7 @@ public NumberOfSubscribedArtistServiceResponse countSubscribedArtists(UUID userI } private List getSubscriptionArtistIds(UUID userId) { - List subscriptions = artistSubscriptionUseCase.findSubscriptionList( - userId); + List subscriptions = artistSubscriptionUseCase.findSubscriptionList(userId); return subscriptions.stream() .map(ArtistSubscription::getArtistId) diff --git a/app/api/show-api/src/main/java/com/example/artist/service/dto/request/ArtistUnsubscriptionPaginationServiceRequest.java b/app/api/show-api/src/main/java/com/example/artist/service/dto/request/ArtistUnsubscriptionPaginationServiceRequest.java index f1bae7f9..4ce9bed9 100644 --- a/app/api/show-api/src/main/java/com/example/artist/service/dto/request/ArtistUnsubscriptionPaginationServiceRequest.java +++ b/app/api/show-api/src/main/java/com/example/artist/service/dto/request/ArtistUnsubscriptionPaginationServiceRequest.java @@ -23,14 +23,6 @@ public record ArtistUnsubscriptionPaginationServiceRequest( ) { public ArtistPaginationDomainRequest toDomainRequest(List artistIds) { - return buildDomainRequest(artistIds); - } - - public ArtistPaginationDomainRequest toNonUserDomainRequest() { - return buildDomainRequest(List.of()); - } - - private ArtistPaginationDomainRequest buildDomainRequest(List artistIds) { var artistGenders = artistGenderApiTypes.stream() .map(ArtistGenderApiType::toDomainType) .toList(); diff --git a/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistKoreanNameWithShowIdServiceResponse.java b/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistKoreanNameWithShowIdServiceResponse.java deleted file mode 100644 index 259edf69..00000000 --- a/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistKoreanNameWithShowIdServiceResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.example.artist.service.dto.response; - -import java.util.List; -import java.util.UUID; -import lombok.Builder; -import org.example.dto.artist.response.ArtistKoreanNamesWithShowIdDomainResponse; - -@Builder -public record ArtistKoreanNameWithShowIdServiceResponse( - UUID showId, - List koreanNameServiceResponses -) { - - public static ArtistKoreanNameWithShowIdServiceResponse from( - ArtistKoreanNamesWithShowIdDomainResponse domainResponse - ) { - var koreanNames = domainResponse.koreanNameDomainResponses() - .stream() - .map(ArtistKoreanNameServiceResponse::new) - .toList(); - - return ArtistKoreanNameWithShowIdServiceResponse.builder() - .showId(domainResponse.showId()) - .koreanNameServiceResponses(koreanNames) - .build(); - } -} diff --git a/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistSearchServiceResponse.java b/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistSearchServiceResponse.java deleted file mode 100644 index 61997677..00000000 --- a/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistSearchServiceResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.example.artist.service.dto.response; - -import java.util.UUID; -import org.example.dto.artist.response.ArtistSearchResponse; - -public record ArtistSearchServiceResponse( - UUID id, - String koreanName, - String englishName, - String image -) { - - public ArtistSearchServiceResponse(ArtistSearchResponse artistSearchResponse) { - this( - artistSearchResponse.id(), - artistSearchResponse.koreanName(), - artistSearchResponse.englishName(), - artistSearchResponse.image() - ); - } -} diff --git a/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistSubscriptionPaginationServiceResponse.java b/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistSubscriptionPaginationServiceResponse.java deleted file mode 100644 index 0d7d1c70..00000000 --- a/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistSubscriptionPaginationServiceResponse.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.artist.service.dto.response; - -import com.example.artist.service.dto.param.ArtistSubscriptionPaginationServiceParam; -import java.util.List; -import lombok.Builder; - -@Builder -public record ArtistSubscriptionPaginationServiceResponse( - boolean hasNext, - List data -) { - -} diff --git a/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistUnsubscriptionPaginationServiceResponse.java b/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistUnsubscriptionPaginationServiceResponse.java deleted file mode 100644 index 897fcfc5..00000000 --- a/app/api/show-api/src/main/java/com/example/artist/service/dto/response/ArtistUnsubscriptionPaginationServiceResponse.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.artist.service.dto.response; - -import com.example.artist.service.dto.param.ArtistSubscriptionPaginationServiceParam; -import java.util.List; -import lombok.Builder; - -@Builder -public record ArtistUnsubscriptionPaginationServiceResponse( - boolean hasNext, - List data -) { - -} diff --git a/app/api/show-api/src/main/java/com/example/component/ViewCountComponent.java b/app/api/show-api/src/main/java/com/example/component/ViewCountComponent.java index 43a28588..0f950e2d 100644 --- a/app/api/show-api/src/main/java/com/example/component/ViewCountComponent.java +++ b/app/api/show-api/src/main/java/com/example/component/ViewCountComponent.java @@ -4,5 +4,5 @@ public interface ViewCountComponent { - boolean validateViewCount(UUID showId, String viewIdentifier); + boolean validateViewCount(UUID showId, String deviceToken); } 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 60504653..74c31cce 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 @@ -15,9 +15,11 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.util.UUID; import lombok.RequiredArgsConstructor; import org.example.dto.response.PaginationApiResponse; -import org.example.security.dto.AuthenticatedUser; +import org.example.security.dto.AuthenticatedInfo; +import org.example.util.ValidatorUser; import org.springdoc.core.annotations.ParameterObject; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -38,10 +40,11 @@ public class GenreController { @GetMapping @Operation(summary = "장르 전체 목록 조회") public ResponseEntity> getGenres( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @ParameterObject GenrePaginationApiRequest request ) { - var response = genreService.findGenres(request.toServiceRequest(user)); + UUID userId = ValidatorUser.getUserId(info); + var response = genreService.findGenres(request.toServiceRequest(userId)); var data = response.data().stream() .map(GenrePaginationApiParam::new) .toList(); @@ -57,11 +60,11 @@ public ResponseEntity> getGenres( @GetMapping("/unsubscriptions") @Operation(summary = "구독하지 않은 장르 목록 조회") public ResponseEntity> getUnsubscribedGenres( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @ParameterObject GenreUnsubscriptionPaginationApiRequest request ) { var response = genreService.findGenreUnSubscriptions( - request.toServiceRequest(user.userId())); + request.toServiceRequest(info.userId())); var data = response.data().stream() .map(GenreUnsubscriptionPaginationApiParam::new) .toList(); @@ -77,10 +80,10 @@ public ResponseEntity> getSubscribedGenres( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @ParameterObject GenreSubscriptionPaginationApiRequest request ) { - var response = genreService.findGenreSubscriptions(request.toServiceRequest(user.userId())); + var response = genreService.findGenreSubscriptions(request.toServiceRequest(info.userId())); var data = response.data().stream() .map(GenreSubscriptionPaginationApiParam::new) .toList(); @@ -96,11 +99,11 @@ public ResponseEntity @GetMapping("/subscriptions/count") @Operation(summary = "구독한 장르 수") public ResponseEntity getNumberOfSubscribedGenre( - @AuthenticationPrincipal AuthenticatedUser user + @AuthenticationPrincipal AuthenticatedInfo info ) { return ResponseEntity.ok( NumberOfSubscribedGenreApiResponse.from( - genreService.countSubscribedGenres(user.userId()) + genreService.countSubscribedGenres(info.userId()) ) ); } @@ -108,12 +111,12 @@ public ResponseEntity getNumberOfSubscribedG @PostMapping("/subscribe") @Operation(summary = "구독하기") public ResponseEntity subscribe( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @Valid @RequestBody GenreSubscriptionApiRequest request ) { return ResponseEntity.ok( GenreSubscriptionApiResponse.from( - genreService.subscribe(request.toServiceRequest(user.userId())) + genreService.subscribe(request.toServiceRequest(info.userId())) ) ); } @@ -121,12 +124,12 @@ public ResponseEntity subscribe( @PostMapping("/unsubscribe") @Operation(summary = "구독 취소하기") public ResponseEntity unsubscribe( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @Valid @RequestBody GenreUnsubscriptionApiRequest request ) { return ResponseEntity.ok( GenreUnsubscriptionApiResponse.from( - genreService.unsubscribe(request.toServiceRequest(user.userId())) + genreService.unsubscribe(request.toServiceRequest(info.userId())) ) ); } diff --git a/app/api/show-api/src/main/java/com/example/genre/controller/dto/request/GenrePaginationApiRequest.java b/app/api/show-api/src/main/java/com/example/genre/controller/dto/request/GenrePaginationApiRequest.java index 9c74fe71..54e7c4fb 100644 --- a/app/api/show-api/src/main/java/com/example/genre/controller/dto/request/GenrePaginationApiRequest.java +++ b/app/api/show-api/src/main/java/com/example/genre/controller/dto/request/GenrePaginationApiRequest.java @@ -4,7 +4,6 @@ import com.example.vo.SubscriptionStatusApiType; import io.swagger.v3.oas.annotations.Parameter; import java.util.UUID; -import org.example.security.dto.AuthenticatedUser; public record GenrePaginationApiRequest( @Parameter(description = "이전 페이지네이션 마지막 데이터의 ID / 최초 조회라면 null") @@ -14,9 +13,7 @@ public record GenrePaginationApiRequest( int size ) { - public GenrePaginationServiceRequest toServiceRequest(AuthenticatedUser user) { - UUID userId = user == null ? null : user.userId(); - + public GenrePaginationServiceRequest toServiceRequest(UUID userId) { return GenrePaginationServiceRequest.builder() .type(SubscriptionStatusApiType.DEFAULTED) .cursor(cursor) diff --git a/app/api/show-api/src/main/java/com/example/genre/controller/dto/response/GenrePaginationApiResponse.java b/app/api/show-api/src/main/java/com/example/genre/controller/dto/response/GenrePaginationApiResponse.java deleted file mode 100644 index 38c0e777..00000000 --- a/app/api/show-api/src/main/java/com/example/genre/controller/dto/response/GenrePaginationApiResponse.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.example.genre.controller.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.List; - -public record GenrePaginationApiResponse( - - @Schema(description = "장르 목록") - List genres, - - @Schema(description = "다음 페이지 존재 여부") - boolean hasNext -) { - -} diff --git a/app/api/show-api/src/main/java/com/example/genre/controller/dto/response/GenreSimpleApiResponse.java b/app/api/show-api/src/main/java/com/example/genre/controller/dto/response/GenreSimpleApiResponse.java deleted file mode 100644 index 8c680e65..00000000 --- a/app/api/show-api/src/main/java/com/example/genre/controller/dto/response/GenreSimpleApiResponse.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.example.genre.controller.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.UUID; - -public record GenreSimpleApiResponse( - - @Schema(description = "장르 ID") - UUID id, - - @Schema(description = "장르 이름") - String name, - - @Schema(description = "장르 이미지 주소") - String image -) { - -} diff --git a/app/api/show-api/src/main/java/com/example/genre/service/dto/response/GenreNameWithShowIdServiceResponse.java b/app/api/show-api/src/main/java/com/example/genre/service/dto/response/GenreNameWithShowIdServiceResponse.java deleted file mode 100644 index c2eadb9a..00000000 --- a/app/api/show-api/src/main/java/com/example/genre/service/dto/response/GenreNameWithShowIdServiceResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.example.genre.service.dto.response; - -import java.util.List; -import java.util.UUID; -import org.example.dto.genre.response.GenreNamesWithShowIdDomainResponse; - -public record GenreNameWithShowIdServiceResponse( - UUID showId, - List genreNames -) { - - public GenreNameWithShowIdServiceResponse( - GenreNamesWithShowIdDomainResponse response - ) { - this( - response.showId(), - response.genreNames().stream() - .map(GenreNameServiceResponse::new) - .toList() - ); - } - -} diff --git a/app/api/show-api/src/main/java/com/example/genre/service/dto/response/GenreSubscriptionPaginationServiceResponse.java b/app/api/show-api/src/main/java/com/example/genre/service/dto/response/GenreSubscriptionPaginationServiceResponse.java deleted file mode 100644 index 8879118f..00000000 --- a/app/api/show-api/src/main/java/com/example/genre/service/dto/response/GenreSubscriptionPaginationServiceResponse.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.genre.service.dto.response; - -import com.example.genre.service.dto.param.GenreSubscriptionPaginationServiceParam; -import java.util.List; -import lombok.Builder; - -@Builder -public record GenreSubscriptionPaginationServiceResponse( - boolean hasNext, - List data -) { - -} 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 13d71142..5a91c604 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 @@ -13,7 +13,7 @@ import lombok.RequiredArgsConstructor; import org.example.dto.response.PaginationApiResponse; import org.example.dto.response.PaginationServiceResponse; -import org.example.security.dto.AuthenticatedUser; +import org.example.security.dto.AuthenticatedInfo; import org.example.util.ValidatorUser; import org.springdoc.core.annotations.ParameterObject; import org.springframework.http.ResponseEntity; @@ -57,14 +57,14 @@ public ResponseEntity> getShows( @GetMapping("/{showId}") @Operation(summary = "공연 상세 조회") public ResponseEntity getShow( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @PathVariable("showId") UUID showId, - @RequestHeader(value = "viewIdentifier") String viewIdentifier + @RequestHeader(value = "Device-Token") String deviceToken ) { - UUID userId = ValidatorUser.getUserId(user); + UUID userId = ValidatorUser.getUserId(info); return ResponseEntity.ok( - ShowDetailApiResponse.from(showService.getShow(userId, showId, viewIdentifier)) + ShowDetailApiResponse.from(showService.getShow(userId, showId, deviceToken)) ); } 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 index a5c98dbc..1d4ac6c3 100644 --- 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 @@ -23,7 +23,7 @@ import lombok.RequiredArgsConstructor; import org.example.dto.response.PaginationApiResponse; import org.example.dto.response.PaginationServiceResponse; -import org.example.security.dto.AuthenticatedUser; +import org.example.security.dto.AuthenticatedInfo; import org.springdoc.core.annotations.ParameterObject; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -47,14 +47,14 @@ public class UserShowController { @Operation(summary = "공연 관심 등록 / 취소") public ResponseEntity interest( @PathVariable("showId") UUID showId, - @AuthenticationPrincipal AuthenticatedUser user + @AuthenticationPrincipal AuthenticatedInfo info ) { return ResponseEntity.ok( ShowInterestApiResponse.from( userShowService.interest( ShowInterestServiceRequest.builder() .showId(showId) - .userId(user.userId()) + .userId(info.userId()) .build() ) ) @@ -65,10 +65,10 @@ public ResponseEntity interest( @Operation(summary = "공연 관심 목록 조회") public ResponseEntity> getInterests( @ParameterObject ShowInterestPaginationApiRequest request, - @AuthenticationPrincipal AuthenticatedUser user + @AuthenticationPrincipal AuthenticatedInfo info ) { var serviceResponse = userShowService.findInterestShows( - request.toServiceRequest(user.userId()) + request.toServiceRequest(info.userId()) ); List response = serviceResponse.data().stream() @@ -86,11 +86,11 @@ public ResponseEntity> @GetMapping("/interests/count") @Operation(summary = "관심 공연 개수") public ResponseEntity getNumberOfInterestShow( - @AuthenticationPrincipal AuthenticatedUser user + @AuthenticationPrincipal AuthenticatedInfo info ) { return ResponseEntity.ok( NumberOfInterestShowApiResponse.from( - userShowService.countInterestShows(user.userId()) + userShowService.countInterestShows(info.userId()) ) ); } @@ -101,13 +101,13 @@ public ResponseEntity getNumberOfInterestShow( description = "요청한 알람 시간으로 기존 내용을 덮어쓴다." ) public ResponseEntity alert( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @PathVariable("showId") UUID showId, @RequestParam("ticketingApiType") TicketingApiType type, @Valid @RequestBody TicketingAlertReservationApiRequest ticketingAlertReservationRequest ) { userShowService.alertReservation( - ticketingAlertReservationRequest.toServiceRequest(user.userId(), showId, type) + ticketingAlertReservationRequest.toServiceRequest(info.userId(), showId, type) ); return ResponseEntity.noContent().build(); @@ -116,11 +116,11 @@ public ResponseEntity alert( @GetMapping("/alerts") @Operation(summary = "공연 알림 목록 조회") public ResponseEntity> getAlerts( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @ParameterObject ShowAlertPaginationApiRequest request ) { PaginationServiceResponse alertShows = userShowService.findAlertShows( - request.toServiceRequest(user.userId())); + request.toServiceRequest(info.userId())); var showAlertPaginationApiParams = alertShows.data().stream() .map(ShowAlertPaginationApiParam::from) @@ -137,14 +137,14 @@ public ResponseEntity> getAle @GetMapping("/{showId}/alert/reservations") @Operation(summary = "공연 티켓팅 알림 예약 조회") public ResponseEntity getAlertsReservations( - @AuthenticationPrincipal AuthenticatedUser user, + @AuthenticationPrincipal AuthenticatedInfo info, @PathVariable("showId") UUID showId, @RequestParam("ticketingApiType") TicketingApiType type ) { var now = LocalDateTime.now(); return ResponseEntity.ok( TicketingAlertReservationApiResponse.from( - userShowService.findAlertsReservations(user.userId(), showId, type, now) + userShowService.findAlertsReservations(info.userId(), showId, type, now) ) ); } @@ -152,12 +152,12 @@ public ResponseEntity getAlertsReservation @GetMapping("/alerts/count") @Operation(summary = "알림 설정한 공연 개수") public ResponseEntity getNumberOfAlertShow( - @AuthenticationPrincipal AuthenticatedUser user + @AuthenticationPrincipal AuthenticatedInfo info ) { LocalDateTime now = LocalDateTime.now(); return ResponseEntity.ok( NumberOfTicketingAlertApiResponse.from( - userShowService.countAlertShows(user.userId(), now) + userShowService.countAlertShows(info.userId(), now) ) ); } @@ -165,11 +165,11 @@ public ResponseEntity getNumberOfAlertShow( @GetMapping("/terminated/ticketing/count") @Operation(summary = "티켓팅 알림 설정 후 공연이 종료된 개수") public ResponseEntity getNumberOfTerminatedTicketingShowCount( - @AuthenticationPrincipal AuthenticatedUser user + @AuthenticationPrincipal AuthenticatedInfo info ) { return ResponseEntity.ok( TerminatedTicketingShowCountApiResponse.from( - userShowService.countTerminatedTicketingShow(user.userId()) + userShowService.countTerminatedTicketingShow(info.userId()) ) ); } diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowAlertPaginationApiResponse.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowAlertPaginationApiResponse.java deleted file mode 100644 index 263f07f4..00000000 --- a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowAlertPaginationApiResponse.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.show.controller.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.List; -import lombok.Builder; - -@Builder -public record ShowAlertPaginationApiResponse( - - @Schema(description = "공연 목록") - List shows, - - @Schema(description = "다음 페이지 존재 여부") - boolean hasNext -) { - -} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowArtistPaginationApiParam.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowArtistPaginationApiParam.java deleted file mode 100644 index 764bf51b..00000000 --- a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowArtistPaginationApiParam.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.example.show.controller.dto.response; - -import com.example.show.service.dto.response.ShowArtistSimpleServiceResponse; -import java.util.UUID; -import lombok.Builder; - -@Builder -public record ShowArtistPaginationApiParam( - UUID id, - String koreanName, - String englishName, - String imageURL -) { - - public static ShowArtistPaginationApiParam from(ShowArtistSimpleServiceResponse response) { - return ShowArtistPaginationApiParam.builder() - .id(response.id()) - .koreanName(response.koreanName()) - .englishName(response.englishName()) - .imageURL(response.image()) - .build(); - } -} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowArtistSimpleApiResponse.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowArtistSimpleApiResponse.java deleted file mode 100644 index 0bb620b8..00000000 --- a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowArtistSimpleApiResponse.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example.show.controller.dto.response; - -import java.util.UUID; -import lombok.Builder; - -@Builder -public record ShowArtistSimpleApiResponse( - UUID id, - String koreanName, - String englishName, - String image -) { - -} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowGenrePaginationApiParam.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowGenrePaginationApiParam.java deleted file mode 100644 index b7c7132b..00000000 --- a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowGenrePaginationApiParam.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.example.show.controller.dto.response; - -import com.example.show.service.dto.response.ShowGenreSimpleServiceResponse; -import java.util.UUID; -import lombok.Builder; - -@Builder -public record ShowGenrePaginationApiParam( - UUID id, - String name -) { - - public static ShowGenrePaginationApiParam from(ShowGenreSimpleServiceResponse response) { - return ShowGenrePaginationApiParam.builder() - .id(response.id()) - .name(response.name()) - .build(); - } -} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowGenreSimpleApiResponse.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowGenreSimpleApiResponse.java deleted file mode 100644 index 9ec61256..00000000 --- a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowGenreSimpleApiResponse.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.show.controller.dto.response; - -public record ShowGenreSimpleApiResponse( - String id, - String name -) { - -} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowSimpleApiResponse.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowSimpleApiResponse.java deleted file mode 100644 index 4122a2f0..00000000 --- a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowSimpleApiResponse.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.example.show.controller.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.UUID; -import lombok.Builder; - -@Builder -public record ShowSimpleApiResponse( - - @Schema(description = "공연 ID") - UUID id, - - @Schema(description = "공연 이름") - String title, - - @Schema(description = "공연 장소") - String location, - - @Schema(description = "아티스트 정보") - ShowArtistSimpleApiResponse artist, - - @Schema(description = "장르 정보") - ShowGenreSimpleApiResponse genre, - - @Schema(description = "공연 포스터 이미지 주소") - String posterImageURL, - - @Schema(description = "예매일") - String reservationDate, - - @Schema(description = "오픈 예정인 티켓팅 일정이 있는지 여부") - boolean hasTicketingOpenSchedule -) { - -} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowTicketingTimePaginationApiParam.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowTicketingTimePaginationApiParam.java deleted file mode 100644 index c9e4b489..00000000 --- a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowTicketingTimePaginationApiParam.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.example.show.controller.dto.response; - -import com.example.show.controller.vo.TicketingApiType; -import com.example.show.service.dto.response.ShowTicketingTimeServiceParam; -import lombok.Builder; -import org.example.util.DateTimeUtil; - -@Builder -public record ShowTicketingTimePaginationApiParam( - TicketingApiType ticketingType, - String ticketingAt -) { - - public static ShowTicketingTimePaginationApiParam from(ShowTicketingTimeServiceParam response) { - return ShowTicketingTimePaginationApiParam.builder() - .ticketingType(response.ticketingType()) - .ticketingAt(DateTimeUtil.formatDateTime(response.ticketingAt())) - .build(); - } -} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowWithTicketingTimesServiceResponse.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowWithTicketingTimesServiceResponse.java deleted file mode 100644 index 68b7d8e4..00000000 --- a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/ShowWithTicketingTimesServiceResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.example.show.controller.dto.response; - -import com.example.show.service.dto.response.ShowSeatServiceResponse; -import com.example.show.service.dto.response.ShowTicketingSiteServiceResponse; -import com.example.show.service.dto.response.ShowTicketingTimeServiceResponse; -import java.time.LocalDate; -import java.util.List; -import java.util.UUID; -import org.example.dto.show.response.ShowTicketingTimeDomainResponse; -import org.example.dto.show.response.ShowWithTicketingTimesDomainResponse; - -public record ShowWithTicketingTimesServiceResponse( - UUID id, - String title, - String content, - LocalDate startDate, - LocalDate endDate, - String location, - String image, - ShowSeatServiceResponse seats, - ShowTicketingSiteServiceResponse ticketingSiteInfos, - List ticketingTimes -) { - - public ShowWithTicketingTimesServiceResponse( - ShowWithTicketingTimesDomainResponse domainResponse - ) { - this( - domainResponse.show().id(), - domainResponse.show().title(), - domainResponse.show().content(), - domainResponse.show().startDate(), - domainResponse.show().endDate(), - domainResponse.show().location(), - domainResponse.show().image(), - ShowSeatServiceResponse.from(domainResponse.show().seatPrices()), - ShowTicketingSiteServiceResponse.from(domainResponse.show().ticketingSites()), - toShowTicketingTimeServiceResponses(domainResponse.ticketingTimes()) - ); - } - - private static List toShowTicketingTimeServiceResponses( - List ticketingSites - ) { - return ticketingSites.stream() - .map(ShowTicketingTimeServiceResponse::from) - .toList(); - } - -} diff --git a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/TicketingAndShowInfoApiResponse.java b/app/api/show-api/src/main/java/com/example/show/controller/dto/response/TicketingAndShowInfoApiResponse.java deleted file mode 100644 index 30c19a45..00000000 --- a/app/api/show-api/src/main/java/com/example/show/controller/dto/response/TicketingAndShowInfoApiResponse.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.show.controller.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; - -public record TicketingAndShowInfoApiResponse( - - @Schema(description = "티켓팅 시각") - String ticketingDateTime, - - @Schema(description = "공연 시각") - String showDateTime, - - @Schema(description = "티켓팅 링크") - String ticketingURL -) { - -} 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 92131482..a794889e 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 @@ -24,13 +24,13 @@ public class ShowService { private final InterestShowUseCase interestShowUseCase; private final ViewCountComponent viewCountComponent; - public ShowDetailServiceResponse getShow(UUID userId, UUID showId, String viewIdentifier) { + public ShowDetailServiceResponse getShow(UUID userId, UUID showId, String deviceToken) { ShowDetailDomainResponse showDetail = showUseCase.findShowDetail(showId); boolean isInterested = userId != null && interestShowUseCase.findInterestShow(showId, userId).isPresent(); - if (viewCountComponent.validateViewCount(showId, viewIdentifier)) { + if (viewCountComponent.validateViewCount(showId, deviceToken)) { showUseCase.view(showId); } 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 68453876..682b69a0 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 @@ -457,13 +457,14 @@ void artistUnsubscribeForNonUserWithPagination() { given( artistUseCase.findAllArtistInCursorPagination( - request.toNonUserDomainRequest()) + request.toDomainRequest(List.of()) + ) ).willReturn( ArtistResponseDtoFixture.artistPaginationDomainResponse(size, hasNext) ); //when - var result = artistService.findArtistUnsubscriptionsForNonUser(request); + var result = artistService.findArtistUnsubscriptions(request); //then SoftAssertions.assertSoftly( diff --git a/app/api/user-api/src/main/java/org/example/controller/UserController.java b/app/api/user-api/src/main/java/org/example/controller/UserController.java index 6c947f5f..01c080ca 100644 --- a/app/api/user-api/src/main/java/org/example/controller/UserController.java +++ b/app/api/user-api/src/main/java/org/example/controller/UserController.java @@ -5,13 +5,10 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.example.controller.dto.request.LoginApiRequest; -import org.example.controller.dto.request.LogoutApiRequest; -import org.example.controller.dto.request.ReissueApiRequest; -import org.example.controller.dto.request.WithdrawalApiRequest; import org.example.controller.dto.response.LoginApiResponse; import org.example.controller.dto.response.ReissueApiResponse; import org.example.controller.dto.response.UserProfileApiResponse; -import org.example.security.dto.AuthenticatedUser; +import org.example.security.dto.AuthenticatedInfo; import org.example.security.dto.TokenParam; import org.example.service.UserService; import org.springframework.http.ResponseEntity; @@ -46,29 +43,27 @@ public ResponseEntity signUp(@Valid @RequestBody LoginApiReque @PostMapping("/logout") @Operation(summary = "로그아웃") public ResponseEntity logout( - @AuthenticationPrincipal AuthenticatedUser user, - @Valid @RequestBody LogoutApiRequest request + @AuthenticationPrincipal AuthenticatedInfo info ) { - userService.logout(request.toServiceRequest(user.userId())); + userService.logout(info.userId(), info.accessToken()); return ResponseEntity.noContent().build(); } @PostMapping("/withdrawal") @Operation(summary = "회원탈퇴") public ResponseEntity withdraw( - @AuthenticationPrincipal AuthenticatedUser user, - @Valid @RequestBody WithdrawalApiRequest request + @AuthenticationPrincipal AuthenticatedInfo info ) { - userService.withdraw(request.toServiceRequest(user.userId())); + userService.withdraw(info.userId(), info.accessToken()); return ResponseEntity.noContent().build(); } @PostMapping("/reissue") @Operation(summary = "토큰 재발급") public ResponseEntity reissue( - @Valid @RequestBody ReissueApiRequest request + @AuthenticationPrincipal AuthenticatedInfo info ) { - TokenParam reissueToken = userService.reissue(request.toServiceRequest()); + TokenParam reissueToken = userService.reissue(info.userId(), info.refreshToken()); return ResponseEntity.ok( ReissueApiResponse.builder() @@ -81,9 +76,9 @@ public ResponseEntity reissue( @GetMapping("/profile") @Operation(summary = "회원 정보") public ResponseEntity profile( - @AuthenticationPrincipal AuthenticatedUser user + @AuthenticationPrincipal AuthenticatedInfo info ) { - var profile = userService.findUserProfile(user.userId()); + var profile = userService.findUserProfile(info.userId()); return ResponseEntity.ok( UserProfileApiResponse.from(profile) diff --git a/app/api/user-api/src/main/java/org/example/controller/dto/request/LogoutApiRequest.java b/app/api/user-api/src/main/java/org/example/controller/dto/request/LogoutApiRequest.java deleted file mode 100644 index cbb3fe1e..00000000 --- a/app/api/user-api/src/main/java/org/example/controller/dto/request/LogoutApiRequest.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.example.controller.dto.request; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; -import java.util.UUID; -import org.example.service.dto.request.LogoutServiceRequest; - -public record LogoutApiRequest( - @Schema(description = "인증 토큰") - @NotNull(message = "accessToken은 필수 입력값입니다.") - String accessToken -) { - - public LogoutServiceRequest toServiceRequest(UUID userId) { - return LogoutServiceRequest.builder() - .accessToken(accessToken) - .userId(userId) - .build(); - } -} diff --git a/app/api/user-api/src/main/java/org/example/controller/dto/request/ReissueApiRequest.java b/app/api/user-api/src/main/java/org/example/controller/dto/request/ReissueApiRequest.java deleted file mode 100644 index 3a89a9cd..00000000 --- a/app/api/user-api/src/main/java/org/example/controller/dto/request/ReissueApiRequest.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.example.controller.dto.request; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; -import org.example.service.dto.request.ReissueServiceRequest; - -public record ReissueApiRequest( - @Schema(description = "재발급 토큰") - @NotNull(message = "refreshToken은 필수 입력값입니다.") - String refreshToken -) { - - public ReissueServiceRequest toServiceRequest() { - return new ReissueServiceRequest(refreshToken); - } -} diff --git a/app/api/user-api/src/main/java/org/example/controller/dto/request/WithdrawalApiRequest.java b/app/api/user-api/src/main/java/org/example/controller/dto/request/WithdrawalApiRequest.java deleted file mode 100644 index 49432c88..00000000 --- a/app/api/user-api/src/main/java/org/example/controller/dto/request/WithdrawalApiRequest.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.example.controller.dto.request; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; -import java.util.UUID; -import org.example.service.dto.request.WithdrawalServiceRequest; - -public record WithdrawalApiRequest( - - @Schema(description = "인증 토큰") - @NotNull(message = "accessToken은 필수 입력값입니다.") - String accessToken -) { - - public WithdrawalServiceRequest toServiceRequest(UUID userId) { - return WithdrawalServiceRequest.builder() - .accessToken(accessToken) - .userId(userId) - .build(); - } -} 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 7ab41822..8c3c786b 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 @@ -12,9 +12,6 @@ import org.example.security.token.JWTGenerator; import org.example.security.token.TokenProcessor; import org.example.service.dto.request.LoginServiceRequest; -import org.example.service.dto.request.LogoutServiceRequest; -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; @@ -44,27 +41,29 @@ public TokenParam login(LoginServiceRequest loginServiceRequest) { return jwtGenerator.generate(userParam, new Date()); } - public void logout(LogoutServiceRequest request) { + public void logout(UUID userId, String accessToken) { + User user = userUseCase.findByIdOrElseThrow(userId); tokenProcessor.makeAccessTokenBlacklistAndDeleteRefreshToken( - request.accessToken(), - request.userId() + accessToken, + user.getId() ); } - public void withdraw(WithdrawalServiceRequest request) { + public void withdraw(UUID userId, String accessToken) { transactionTemplate.executeWithoutResult(status -> { - User user = userUseCase.deleteUser(request.userId()); + User user = userUseCase.deleteUser(userId); deleteAssociatedWithUser(user); }); tokenProcessor.makeAccessTokenBlacklistAndDeleteRefreshToken( - request.accessToken(), - request.userId() + accessToken, + userId ); } - public TokenParam reissue(ReissueServiceRequest request) { - return tokenProcessor.reissueToken(request.refreshToken()); + public TokenParam reissue(UUID userId, String refreshToken) { + userUseCase.findByIdOrElseThrow(userId); + return tokenProcessor.reissueToken(refreshToken); } public UserProfileServiceResponse findUserProfile(UUID userId) { diff --git a/app/api/user-api/src/main/java/org/example/service/dto/request/LogoutServiceRequest.java b/app/api/user-api/src/main/java/org/example/service/dto/request/LogoutServiceRequest.java deleted file mode 100644 index e05986cf..00000000 --- a/app/api/user-api/src/main/java/org/example/service/dto/request/LogoutServiceRequest.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.example.service.dto.request; - -import java.util.UUID; -import lombok.Builder; - -@Builder -public record LogoutServiceRequest( - String accessToken, - UUID userId -) { - -} diff --git a/app/api/user-api/src/main/java/org/example/service/dto/request/ReissueServiceRequest.java b/app/api/user-api/src/main/java/org/example/service/dto/request/ReissueServiceRequest.java deleted file mode 100644 index bd5bed1e..00000000 --- a/app/api/user-api/src/main/java/org/example/service/dto/request/ReissueServiceRequest.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.example.service.dto.request; - -public record ReissueServiceRequest( - String refreshToken -) { - -} diff --git a/app/api/user-api/src/main/java/org/example/service/dto/request/WithdrawalServiceRequest.java b/app/api/user-api/src/main/java/org/example/service/dto/request/WithdrawalServiceRequest.java deleted file mode 100644 index 5deb58d6..00000000 --- a/app/api/user-api/src/main/java/org/example/service/dto/request/WithdrawalServiceRequest.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.example.service.dto.request; - -import java.util.UUID; -import lombok.Builder; - -@Builder -public record WithdrawalServiceRequest( - String accessToken, - UUID userId -) { - -} diff --git a/app/domain/show-domain/src/main/java/org/example/dto/artist/response/ArtistSearchResponse.java b/app/domain/show-domain/src/main/java/org/example/dto/artist/response/ArtistSearchResponse.java deleted file mode 100644 index 20de5f29..00000000 --- a/app/domain/show-domain/src/main/java/org/example/dto/artist/response/ArtistSearchResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.example.dto.artist.response; - -import java.util.UUID; - -public record ArtistSearchResponse( - UUID id, - String koreanName, - String englishName, - String image -) { - -} diff --git a/app/domain/show-domain/src/main/java/org/example/dto/show/response/ShowPaginationDomainResponse.java b/app/domain/show-domain/src/main/java/org/example/dto/show/response/ShowPaginationDomainResponse.java deleted file mode 100644 index a5cdee71..00000000 --- a/app/domain/show-domain/src/main/java/org/example/dto/show/response/ShowPaginationDomainResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.example.dto.show.response; - -import java.util.List; -import lombok.Builder; - -@Builder -public record ShowPaginationDomainResponse( - boolean hasNext, - List data -) { - -} 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 666f09ed..9a93ddb7 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 @@ -38,8 +38,7 @@ public User findUser(LoginDomainRequest request) { request.identifier() ).orElseThrow(NoSuchElementException::new); - User user = userRepository.findById(socialLogin.getUserId()) - .orElseThrow(NoSuchElementException::new); + User user = findByIdOrElseThrow(socialLogin.getUserId()); if (user.isWithdrew()) { throw new BusinessException(UserError.WITHDREW_USER_LOGIN); @@ -51,7 +50,7 @@ public User findUser(LoginDomainRequest request) { } public User deleteUser(UUID userId) { - User user = userRepository.findById(userId).orElseThrow(NoSuchElementException::new); + User user = findByIdOrElseThrow(userId); userRepository.delete(user); socialLoginRepository.deleteAllByUserId(user.getId()); return user; @@ -64,4 +63,8 @@ public UserProfileDomainResponse findUserProfile(UUID userId) { public String findUserFcmTokensByUserId(UUID userId) { return userRepository.findUserFcmTokensByUserId(userId).orElseThrow(NoSuchElementException::new); } + + public User findByIdOrElseThrow(UUID userId) { + return userRepository.findById(userId).orElseThrow(NoSuchElementException::new); + } } diff --git a/app/infrastructure/redis/src/main/java/org/example/repository/RedisTokenRepository.java b/app/infrastructure/redis/src/main/java/org/example/repository/RedisTokenRepository.java index e8820087..4781b51d 100644 --- a/app/infrastructure/redis/src/main/java/org/example/repository/RedisTokenRepository.java +++ b/app/infrastructure/redis/src/main/java/org/example/repository/RedisTokenRepository.java @@ -41,7 +41,12 @@ public boolean existAccessTokenInBlacklist(UUID userId, String accessToken) { } @Override - public void deleteRefreshToken(UUID userId) { - stringRedisTemplate.delete("RT:" + userId); + public boolean deleteRefreshToken(UUID userId) { + Boolean result = stringRedisTemplate.delete("RT:" + userId); + + if (result == null) { + return false; + } + return result; } } diff --git a/app/infrastructure/redis/src/main/java/org/example/repository/RedisViewCountComponent.java b/app/infrastructure/redis/src/main/java/org/example/repository/RedisViewCountComponent.java index d7c8b484..9a9d3942 100644 --- a/app/infrastructure/redis/src/main/java/org/example/repository/RedisViewCountComponent.java +++ b/app/infrastructure/redis/src/main/java/org/example/repository/RedisViewCountComponent.java @@ -14,12 +14,12 @@ public class RedisViewCountComponent implements ViewCountComponent { private final StringRedisTemplate stringRedisTemplate; @Override - public boolean validateViewCount(UUID showId, String viewIdentifier) { - String viewStatus = stringRedisTemplate.opsForValue().get("VC:" + viewIdentifier + showId); + public boolean validateViewCount(UUID showId, String deviceToken) { + String viewStatus = stringRedisTemplate.opsForValue().get("VC:" + deviceToken + showId); if (viewStatus == null) { stringRedisTemplate.opsForValue() - .set("VC:" + viewIdentifier + showId, "1", 1, TimeUnit.DAYS); + .set("VC:" + deviceToken + ":" + showId, "1", 1, TimeUnit.DAYS); return true; }