-
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.
Merge branch 'develop' into feature/98
- Loading branch information
Showing
19 changed files
with
608 additions
and
94 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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.oduck.api.domain.admin.dto; | ||
|
||
import io.oduck.api.domain.anime.entity.Status; | ||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
public class AdminReq { | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public static class SearchFilter { | ||
private List<Integer> years; | ||
private List<Status> statuses; | ||
private Boolean isReleased; | ||
} | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum QueryType { | ||
TITLE("title"), | ||
SERIES("series"), | ||
ID("id"); | ||
|
||
private final String type; | ||
} | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum Sort { | ||
LATEST("createdAt"), | ||
SERIES("series"), | ||
TITLE("title"), | ||
BOOKMARK_COUNT("bookmarkCount"), | ||
SCORE_TOTAL("starRatingScoreTotal"), | ||
SCORE_COUNT("starRatingCount"), | ||
REVIEW_COUNT("reviewCount"), | ||
VIEW_COUNT("viewCount"); | ||
|
||
private final String sort; | ||
} | ||
} |
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,57 @@ | ||
package io.oduck.api.domain.admin.dto; | ||
|
||
import io.oduck.api.domain.anime.entity.Quarter; | ||
import io.oduck.api.domain.anime.entity.Status; | ||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
|
||
public class AdminRes { | ||
|
||
@Getter | ||
public static class SearchResult { | ||
private Long id; | ||
private String title; | ||
private String thumbnail; | ||
private int year; | ||
private Quarter quarter; | ||
private Boolean isReleased; | ||
private Status status; | ||
private LocalDateTime createdAt; | ||
private Long seriesId; | ||
private String seriesTitle; | ||
private Long bookmarkCount; | ||
private Long starRatingScoreTotal; | ||
private Long starRatingCount; | ||
private double starRatingAvg; | ||
private Long reviewCount; | ||
private Long viewCount; | ||
|
||
public SearchResult(Long id, String title, String thumbnail, int year, Quarter quarter, | ||
boolean isReleased, Status status, LocalDateTime createdAt, Long seriesId, String seriesTitle, | ||
Long bookmarkCount, Long starRatingScoreTotal, Long starRatingCount, Long reviewCount, Long viewCount) { | ||
this.id = id; | ||
this.title = title; | ||
this.thumbnail = thumbnail; | ||
this.year = year; | ||
this.quarter = quarter; | ||
this.isReleased = isReleased; | ||
this.status = status; | ||
this.createdAt = createdAt; | ||
this.seriesId = seriesId; | ||
this.seriesTitle = seriesTitle; | ||
this.bookmarkCount = bookmarkCount; | ||
this.starRatingScoreTotal = starRatingScoreTotal; | ||
this.starRatingCount = starRatingCount; | ||
this.starRatingAvg = calculateAvg(starRatingScoreTotal, starRatingCount); | ||
this.reviewCount = reviewCount; | ||
this.viewCount = viewCount; | ||
} | ||
|
||
private double calculateAvg(Long starRatingScoreTotal, Long starRatingCount) { | ||
if(starRatingCount <= 0) { | ||
return 0; | ||
} | ||
return starRatingScoreTotal / starRatingCount; | ||
} | ||
} | ||
} |
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
9 changes: 8 additions & 1 deletion
9
src/main/java/io/oduck/api/domain/anime/repository/AnimeRepositoryCustom.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,11 +1,18 @@ | ||
package io.oduck.api.domain.anime.repository; | ||
|
||
import io.oduck.api.domain.admin.dto.AdminReq.QueryType; | ||
import io.oduck.api.domain.admin.dto.AdminReq.SearchFilter; | ||
import io.oduck.api.domain.admin.dto.AdminRes; | ||
import io.oduck.api.domain.anime.dto.SearchFilterDsl; | ||
import io.oduck.api.global.common.PageResponse; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
|
||
import static io.oduck.api.domain.anime.dto.AnimeRes.SearchResult; | ||
|
||
public interface AnimeRepositoryCustom { | ||
Slice<SearchResult> findAnimesByCondition(String query, String cursor, Pageable pageable, SearchFilterDsl searchFilterDsl); | ||
Slice<SearchResult> findSliceByCondition(String query, String cursor, Pageable pageable, SearchFilterDsl searchFilterDsl); | ||
|
||
PageResponse<AdminRes.SearchResult> findPageByCondition(String query, QueryType queryType, | ||
Pageable pageable, SearchFilter searchFilter); | ||
} |
Oops, something went wrong.