Skip to content

Commit

Permalink
Merge pull request #16 from Central-MakeUs/refactor/15
Browse files Browse the repository at this point in the history
[Refactor] 도서 검색 관련 필드 추가 및 수정
  • Loading branch information
dainnida authored Jan 20, 2025
2 parents 16e82d9 + 3593fee commit dbf4ba3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public record BookDto(
@Schema(description = "isbn 13자리")
String isbn13,
@Schema(description = "구매 링크")
String link
String link,
@Schema(description = "출판사")
String publisher
) {
// json(item 부분만) -> Book
public static BookDto from(JSONObject itemJson) {
Expand All @@ -28,7 +30,8 @@ public static BookDto from(JSONObject itemJson) {
itemJson.getString("cover"),
itemJson.getString("author"),
itemJson.getString("isbn13"),
cutLink
cutLink,
itemJson.getString("publisher")
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.cmc.mercury.domain.book.search.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

Expand All @@ -13,7 +15,18 @@ public record BookSearchRequest (

@NotNull(message = "정렬 방식은 필수입니다.")
@Schema(description = "정렬 방식(관련도순/출간일순)")
SortType sortType
SortType sortType,

@NotNull(message = "시작 페이지 값은 필수입니다.")
@Min(value = 1, message = "페이지 번호는 1 이상이어야 합니다")
@Schema(description = "검색 결과 시작 페이지(양수, 기본값 1)")
int startPage,

@NotNull(message = "최대 출력 개수는 필수입니다.")
@Min(value = 1, message = "최대 출력 개수는 1 이상이어야 합니다")
@Max(value = 100, message = "최대 출력 개수는 100 이하여야 합니다")
@Schema(description = "검색 결과 한 페이지당 최대 출력 개수(1~100의 양수, 기본값 10)")
int maxResults
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public record BookSearchResponse(

@Schema(description = "Book Dto 객체들")
List<BookDto> books,
@Schema(description = "API의 총 결과 수")
@Schema(description = "API의 총 도서 결과 수")
int totalResults,
@Schema(description = "현재 페이지에 출력된 도서 결과 수")
int currentResults,
@Schema(description = "현재 page 수")
int currentPage, // 현재 페이지 (다음 요청 시 필요)
@Schema(description = "다음 페이지 존재 여부")
Expand All @@ -30,6 +32,7 @@ public static BookSearchResponse from(JSONObject objectResponse, boolean hasNext
return new BookSearchResponse(
books,
objectResponse.getInt("totalResults"),
items.length(),
objectResponse.getInt("startIndex"),
hasNext
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@Getter
public enum SortType {

ACCURACY("Accuracy"), // 관련도순
SALES_POINT("SalesPoint"), // 판매량순
PUBLISH_TIME("PublishTime"); // 출간일순

private final String sortName;
Expand Down

0 comments on commit dbf4ba3

Please sign in to comment.