Skip to content

Commit

Permalink
fix : cursor 스키마 수정 (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
GaBaljaintheroom authored Sep 16, 2024
1 parent d9c85ad commit 6976c13
Show file tree
Hide file tree
Showing 18 changed files with 182 additions and 110 deletions.
1 change: 0 additions & 1 deletion .github/workflows/showpot-dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
pull_request:
branches:
- develop
- temp-develop

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.example.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.UUID;

public record CursorApiResponse(

@Schema(description = "조회한 데이터의 Cursor Id")
UUID id,

@Schema(description = "조회한 데이터의 Cursor Value")
Object value
) {
public static CursorApiResponse toCursorResponse(UUID id, Object value) {
return new CursorApiResponse(id, value);
}

public static CursorApiResponse toCursorId(UUID id) {
return new CursorApiResponse(id, "");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ public class ArtistController {
@Operation(summary = "구독하지 않은 아티스트 목록 조회")
public ResponseEntity<PaginationApiResponse<ArtistUnsubscriptionPaginationApiParam>> getUnsubscribedArtists(
@AuthenticationPrincipal AuthenticatedInfo info,
@ParameterObject ArtistUnsubscriptionPaginationApiRequest request
@Valid @ParameterObject ArtistUnsubscriptionPaginationApiRequest request
) {
UUID userId = ValidatorUser.getUserId(info);
var response = artistService.findArtistUnsubscriptions(request.toServiceRequest(userId));
var response = artistService.findArtistUnsubscriptions(
request.toServiceRequest(info.userId())
);
var data = response.data().stream()
.map(ArtistUnsubscriptionPaginationApiParam::from)
.toList();
Expand All @@ -63,10 +64,11 @@ public ResponseEntity<PaginationApiResponse<ArtistUnsubscriptionPaginationApiPar
@Operation(summary = "구독한 아티스트 목록 조회")
public ResponseEntity<PaginationApiResponse<ArtistSubscriptionPaginationApiParam>> getSubscribedArtists(
@AuthenticationPrincipal AuthenticatedInfo info,
@ParameterObject ArtistSubscriptionPaginationApiRequest request
@Valid @ParameterObject ArtistSubscriptionPaginationApiRequest request
) {
var response = artistService.findArtistSubscriptions(
request.toServiceRequest(info.userId()));
request.toServiceRequest(info.userId())
);
var data = response.data().stream()
.map(ArtistSubscriptionPaginationApiParam::from)
.toList();
Expand Down Expand Up @@ -121,7 +123,7 @@ public ResponseEntity<ArtistUnsubscriptionApiResponse> unsubscribe(
@Operation(summary = "검색하기")
public ResponseEntity<PaginationApiResponse<ArtistSearchPaginationApiParam>> search(
@AuthenticationPrincipal AuthenticatedInfo info,
@ParameterObject ArtistSearchPaginationApiRequest request
@Valid @ParameterObject ArtistSearchPaginationApiRequest request
) {
UUID userId = ValidatorUser.getUserId(info);
var response = artistService.searchArtist(request.toServiceRequest(userId));
Expand All @@ -144,7 +146,8 @@ public ResponseEntity<ArtistFilterTotalCountApiResponse> filterTotalCount(
@Valid @RequestBody ArtistFilterTotalCountApiRequest request
) {
var response = artistService.filterArtistTotalCount(
request.toServiceRequest(info.userId()));
request.toServiceRequest(info.userId())
);

return ResponseEntity.ok(
ArtistFilterTotalCountApiResponse.from(response.totalCount())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.artist.vo.ArtistSortApiType;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import java.util.UUID;

public record ArtistSearchPaginationApiRequest(
Expand All @@ -14,11 +15,12 @@ public record ArtistSearchPaginationApiRequest(
)
ArtistSortApiType sortStandard,

@Parameter(description = "이전 페이지네이션 마지막 데이터의 ID / 최초 조회라면 null")
UUID cursor,
@Parameter(description = "이전 페이지네이션 마지막 데이터의 cursorId / 최초 조회라면 null")
UUID cursorId,

@Parameter(description = "조회하는 데이터 개수", required = true)
int size,
@Parameter(example = "30")
@Max(value = 30, message = "조회하는 데이터의 최대 개수는 30입니다.")
Integer size,

@Parameter(description = "검색어", required = true)
String search
Expand All @@ -28,13 +30,17 @@ public record ArtistSearchPaginationApiRequest(
if (sortStandard == null) {
sortStandard = ArtistSortApiType.ENGLISH_NAME_ASC;
}

if (size == null) {
size = 30;
}
}

public ArtistSearchPaginationServiceRequest toServiceRequest(UUID userId) {
return ArtistSearchPaginationServiceRequest.builder()
.userId(userId)
.sortStandard(sortStandard)
.cursor(cursor)
.cursor(cursorId)
.size(size)
.search(search)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.example.vo.SubscriptionStatusApiType;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import java.util.UUID;

@Schema
Expand All @@ -16,29 +17,30 @@ public record ArtistSubscriptionPaginationApiRequest(
)
ArtistSortApiType sort,

@Parameter(description = "이전 페이지네이션 마지막 데이터의 ID / 최초 조회라면 null")
UUID cursor,
@Parameter(description = "이전 페이지네이션 마지막 데이터의 cursorId / 최초 조회라면 null")
UUID cursorId,

@Parameter(description = "조회하는 데이터 개수", required = true)
int size
@Parameter(example = "30")
@Max(value = 30, message = "조회하는 데이터의 최대 개수는 30입니다.")
Integer size
) {

public ArtistSubscriptionPaginationApiRequest(
ArtistSortApiType sort,
UUID cursor,
int size
UUID cursorId,
Integer size
) {
this.sort = sort == null ? ArtistSortApiType.ENGLISH_NAME_ASC : sort;
this.cursor = cursor;
this.size = size;
this.cursorId = cursorId;
this.size = size == null ? 30 : size;
}

public ArtistSubscriptionPaginationServiceRequest toServiceRequest(UUID userId) {
return ArtistSubscriptionPaginationServiceRequest.builder()
.subscriptionStatusApiType(SubscriptionStatusApiType.SUBSCRIBED)
.size(size)
.sortStandard(sort)
.cursor(cursor)
.cursor(cursorId)
.userId(userId)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import com.example.vo.SubscriptionStatusApiType;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import java.util.List;
import java.util.UUID;
import org.example.util.ValidateStatus;

@Schema
public record ArtistUnsubscriptionPaginationApiRequest(
@Parameter(
description = "정렬 기준, default: ENGLISH_NAME_ASC",
Expand All @@ -28,31 +28,29 @@ public record ArtistUnsubscriptionPaginationApiRequest(
@Parameter(description = "장르 ID 목록")
List<UUID> genreIds,

@Parameter(description = "이전 페이지네이션 마지막 데이터의 ID / 최초 조회라면 null")
UUID cursor,
@Parameter(description = "이전 페이지네이션 마지막 데이터의 cursorId / 최초 조회라면 null")
UUID cursorId,

@Parameter(description = "조회하는 데이터 개수", required = true)
int size
@Parameter(example = "30")
@Max(value = 30, message = "조회하는 데이터의 최대 개수는 30입니다.")
Integer size
) {

public ArtistUnsubscriptionPaginationApiRequest(
ArtistSortApiType sortStandard,
List<ArtistGenderApiType> artistGenderApiTypes,
List<ArtistApiType> artistApiTypes,
List<UUID> genreIds,
UUID cursor,
int size
UUID cursorId,
Integer size
) {
this.sortStandard =
sortStandard == null ? ArtistSortApiType.ENGLISH_NAME_ASC : sortStandard;
this.sortStandard = sortStandard == null ? ArtistSortApiType.ENGLISH_NAME_ASC : sortStandard;
this.artistGenderApiTypes = ValidateStatus.checkNullOrEmpty(artistGenderApiTypes);
this.artistApiTypes = ValidateStatus.checkNullOrEmpty(artistApiTypes);
this.genreIds = ValidateStatus.checkNullOrEmpty(genreIds);
this.cursor = cursor;
this.size = size;
this.cursorId = cursorId;
this.size = size == null ? 30 : size;
}


public ArtistUnsubscriptionPaginationServiceRequest toServiceRequest(UUID userId) {
return ArtistUnsubscriptionPaginationServiceRequest.builder()
.subscriptionStatusApiType(SubscriptionStatusApiType.UNSUBSCRIBED)
Expand All @@ -61,7 +59,7 @@ public ArtistUnsubscriptionPaginationServiceRequest toServiceRequest(UUID userId
.artistApiTypes(artistApiTypes)
.genreIds(genreIds)
.userId(userId)
.cursor(cursor)
.cursor(cursorId)
.size(size)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class GenreController {
@Operation(summary = "장르 전체 목록 조회")
public ResponseEntity<PaginationApiResponse<GenrePaginationApiParam>> getGenres(
@AuthenticationPrincipal AuthenticatedInfo info,
@ParameterObject GenrePaginationApiRequest request
@Valid @ParameterObject GenrePaginationApiRequest request
) {
UUID userId = ValidatorUser.getUserId(info);
var response = genreService.findGenres(request.toServiceRequest(userId));
Expand All @@ -61,10 +61,11 @@ public ResponseEntity<PaginationApiResponse<GenrePaginationApiParam>> getGenres(
@Operation(summary = "구독하지 않은 장르 목록 조회")
public ResponseEntity<PaginationApiResponse<GenreUnsubscriptionPaginationApiParam>> getUnsubscribedGenres(
@AuthenticationPrincipal AuthenticatedInfo info,
@ParameterObject GenreUnsubscriptionPaginationApiRequest request
@Valid @ParameterObject GenreUnsubscriptionPaginationApiRequest request
) {
var response = genreService.findGenreUnSubscriptions(
request.toServiceRequest(info.userId()));
request.toServiceRequest(info.userId())
);
var data = response.data().stream()
.map(GenreUnsubscriptionPaginationApiParam::new)
.toList();
Expand All @@ -81,9 +82,11 @@ public ResponseEntity<PaginationApiResponse<GenreUnsubscriptionPaginationApiPara
@Operation(summary = "구독한 장르 목록 조회")
public ResponseEntity<PaginationApiResponse<GenreSubscriptionPaginationApiParam>> getSubscribedGenres(
@AuthenticationPrincipal AuthenticatedInfo info,
@ParameterObject GenreSubscriptionPaginationApiRequest request
@Valid @ParameterObject GenreSubscriptionPaginationApiRequest request
) {
var response = genreService.findGenreSubscriptions(request.toServiceRequest(info.userId()));
var response = genreService.findGenreSubscriptions(
request.toServiceRequest(info.userId())
);
var data = response.data().stream()
.map(GenreSubscriptionPaginationApiParam::new)
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
import com.example.genre.service.dto.request.GenrePaginationServiceRequest;
import com.example.vo.SubscriptionStatusApiType;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.constraints.Max;
import java.util.UUID;

public record GenrePaginationApiRequest(
@Parameter(description = "이전 페이지네이션 마지막 데이터의 ID / 최초 조회라면 null")
UUID cursor,
@Parameter(description = "이전 페이지네이션 마지막 데이터의 cursorId / 최초 조회라면 null")
UUID cursorId,

@Parameter(description = "조회하는 데이터 개수", required = true)
int size
@Parameter(example = "30")
@Max(value = 30, message = "조회하는 데이터의 최대 개수는 30입니다.")
Integer size
) {
public GenrePaginationApiRequest {
if (size == null) {
size = 30;
}
}

public GenrePaginationServiceRequest toServiceRequest(UUID userId) {
return GenrePaginationServiceRequest.builder()
.type(SubscriptionStatusApiType.DEFAULTED)
.cursor(cursor)
.cursor(cursorId)
.size(size)
.userId(userId)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
import com.example.genre.service.dto.request.GenreSubscriptionPaginationServiceRequest;
import com.example.vo.SubscriptionStatusApiType;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.constraints.Max;
import java.util.UUID;

public record GenreSubscriptionPaginationApiRequest(
@Parameter(description = "이전 페이지네이션 마지막 데이터의 ID / 최초 조회라면 null")
UUID cursor,
@Parameter(description = "이전 페이지네이션 마지막 데이터의 cursorId / 최초 조회라면 null")
UUID cursorId,

@Parameter(description = "조회하는 데이터 개수")
int size
@Parameter(example = "30")
@Max(value = 30, message = "조회하는 데이터의 최대 개수는 30입니다.")
Integer size
) {
public GenreSubscriptionPaginationApiRequest {
if (size == null) {
size = 30;
}
}

public GenreSubscriptionPaginationServiceRequest toServiceRequest(UUID userId) {
return GenreSubscriptionPaginationServiceRequest.builder()
.subscriptionStatusApiType(SubscriptionStatusApiType.SUBSCRIBED)
.cursor(cursor)
.cursor(cursorId)
.size(size)
.userId(userId)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
import com.example.genre.service.dto.request.GenreUnsubscriptionPaginationServiceRequest;
import com.example.vo.SubscriptionStatusApiType;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.constraints.Max;
import java.util.UUID;

public record GenreUnsubscriptionPaginationApiRequest(
@Parameter(description = "이전 페이지네이션 마지막 데이터의 ID / 최초 조회라면 null")
UUID cursor,
@Parameter(description = "이전 페이지네이션 마지막 데이터의 cursorId / 최초 조회라면 null")
UUID cursorId,

@Parameter(description = "조회하는 데이터 개수", required = true)
int size
@Parameter(example = "30")
@Max(value = 30, message = "조회하는 데이터의 최대 개수는 30입니다.")
Integer size
) {
public GenreUnsubscriptionPaginationApiRequest {
if (size == null) {
size = 30;
}
}

public GenreUnsubscriptionPaginationServiceRequest toServiceRequest(UUID userId) {
return GenreUnsubscriptionPaginationServiceRequest.builder()
.subscriptionStatusApiType(SubscriptionStatusApiType.UNSUBSCRIBED)
.cursor(cursor)
.cursor(cursorId)
.size(size)
.userId(userId)
.build();
Expand Down
Loading

0 comments on commit 6976c13

Please sign in to comment.