-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7421c6b
commit 43d79ac
Showing
9 changed files
with
148 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...how-api/src/main/java/com/example/genre/controller/dto/param/GenrePaginationApiParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.example.genre.controller.dto.param; | ||
|
||
import com.example.genre.service.dto.param.GenrePaginationServiceParam; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.util.UUID; | ||
|
||
public record GenrePaginationApiParam( | ||
|
||
@Schema(description = "장르 ID") | ||
UUID id, | ||
|
||
@Schema(description = "장르 이름") | ||
String name, | ||
|
||
@Schema(description = "장르 구독 여부") | ||
boolean isSubscribed | ||
) { | ||
|
||
public GenrePaginationApiParam(GenrePaginationServiceParam param) { | ||
this( | ||
param.id(), | ||
param.name(), | ||
param.isSubscribed() | ||
); | ||
} | ||
} |
25 changes: 17 additions & 8 deletions
25
...api/src/main/java/com/example/genre/controller/dto/request/GenrePaginationApiRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
package com.example.genre.controller.dto.request; | ||
|
||
import com.example.genre.service.dto.request.GenrePaginationServiceRequest; | ||
import com.example.vo.SubscriptionStatusApiType; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import java.util.UUID; | ||
import org.example.pagination.vo.SortDirection; | ||
import org.springdoc.core.annotations.ParameterObject; | ||
import org.example.security.dto.AuthenticatedUser; | ||
|
||
@ParameterObject | ||
public record GenrePaginationApiRequest( | ||
|
||
@Parameter(description = "정렬 방향") | ||
SortDirection sortDirection, | ||
|
||
@Parameter(description = "이전 페이지네이션 마지막 데이터의 ID / 최초 조회라면 null") | ||
UUID cursor | ||
UUID cursor, | ||
|
||
@Parameter(description = "조회하는 데이터 개수", required = true) | ||
int size | ||
) { | ||
|
||
public GenrePaginationServiceRequest toServiceRequest(AuthenticatedUser user) { | ||
UUID userId = user == null ? null : user.userId(); | ||
|
||
return GenrePaginationServiceRequest.builder() | ||
.type(SubscriptionStatusApiType.DEFAULTED) | ||
.cursor(cursor) | ||
.size(size) | ||
.userId(userId) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ow-api/src/main/java/com/example/genre/service/dto/param/GenrePaginationServiceParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.example.genre.service.dto.param; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
import lombok.Builder; | ||
import org.example.dto.genre.response.GenreDomainResponse; | ||
|
||
@Builder | ||
public record GenrePaginationServiceParam( | ||
UUID id, | ||
String name, | ||
boolean isSubscribed | ||
) { | ||
|
||
public static GenrePaginationServiceParam of( | ||
GenreDomainResponse genre, | ||
List<UUID> subscriptionGenreIds | ||
) { | ||
boolean isSubscribed = subscriptionGenreIds.contains(genre.id()); | ||
|
||
return GenrePaginationServiceParam.builder() | ||
.id(genre.id()) | ||
.name(genre.name()) | ||
.isSubscribed(isSubscribed) | ||
.build(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...pi/src/main/java/com/example/genre/service/dto/request/GenrePaginationServiceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.genre.service.dto.request; | ||
|
||
import com.example.vo.SubscriptionStatusApiType; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import lombok.Builder; | ||
import org.example.dto.genre.request.GenrePaginationDomainRequest; | ||
|
||
@Builder | ||
public record GenrePaginationServiceRequest( | ||
SubscriptionStatusApiType type, | ||
UUID cursor, | ||
int size, | ||
UUID userId | ||
) { | ||
public GenrePaginationDomainRequest toDomainRequest() { | ||
return GenrePaginationDomainRequest.builder() | ||
.subscriptionStatus(type.toDomainType()) | ||
.cursor(cursor) | ||
.size(size) | ||
.genreIds(List.of()) | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
|
||
public enum SubscriptionStatus { | ||
SUBSCRIBED, | ||
UNSUBSCRIBED | ||
UNSUBSCRIBED, | ||
DEFAULTED | ||
} |