-
Notifications
You must be signed in to change notification settings - Fork 1
feat: BookDetailResponse에 사용자 도서 상태 및 페이지 정보 추가 #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f1586b5
4b275fc
5fa8152
da20c14
698cbc2
e26349a
cec68cd
e87dd78
e5b23c0
6bb691c
491b538
76193e2
08bb18c
d8d0593
894c9d5
b50c97b
86ca1b0
cb8b0e2
b923e19
94895cc
ee479c6
4ebdc1a
968c794
9e4a8b6
cf02829
0c1d6c7
a84de0f
29a386b
e38eaac
c3d3765
62eabda
75fd264
ea24d9d
70fc7ae
10ba6bd
414d193
91b35e8
a99a698
1f73a87
19cbea0
f9acaa9
804e487
8526a79
1b917e2
61a7d93
033d224
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,38 +1,38 @@ | ||||||
| package org.yapp.apis.book.dto.request | ||||||
|
|
||||||
| import io.swagger.v3.oas.annotations.media.Schema | ||||||
| import jakarta.validation.constraints.NotBlank | ||||||
| import jakarta.validation.constraints.Pattern // Pattern 어노테이션 추가 | ||||||
| import jakarta.validation.constraints.Pattern | ||||||
| import org.yapp.globalutils.util.RegexUtils | ||||||
| import org.yapp.infra.external.aladin.dto.AladinBookLookupRequest | ||||||
|
|
||||||
| @Schema( | ||||||
| title = "책 상세 정보 요청", | ||||||
| description = "특정 ISBN을 통한 책 상세 정보 조회 요청" | ||||||
| ) | ||||||
| data class BookDetailRequest private constructor( | ||||||
| @field:NotBlank(message = "아이템 ID는 필수입니다.") | ||||||
| @field:NotBlank(message = "ISBN은 비어 있을 수 없습니다.") | ||||||
| @field:Pattern( | ||||||
| regexp = RegexUtils.NOT_BLANK_AND_NOT_NULL_STRING_PATTERN, | ||||||
| message = "아이템 ID는 유효한 ISBN 형식이 아닙니다." | ||||||
| regexp = RegexUtils.ISBN13_PATTERN, | ||||||
| message = "유효한 13자리 ISBN 형식이 아닙니다." | ||||||
| ) | ||||||
| val itemId: String? = null, | ||||||
| val itemIdType: String? = "ISBN", | ||||||
| val optResult: List<String>? = null | ||||||
| @Schema( | ||||||
| description = "조회할 책의 13자리 ISBN 코드", | ||||||
| example = "9788932473901", | ||||||
| required = true, | ||||||
| pattern = "\\d{13}", | ||||||
| minLength = 13, | ||||||
| maxLength = 13 | ||||||
| ) | ||||||
| val isbn: String? = null, | ||||||
| ) { | ||||||
|
|
||||||
| fun validIsbn(): String = itemId!! | ||||||
|
|
||||||
|
|
||||||
| fun toAladinRequest(): AladinBookLookupRequest { | ||||||
| return AladinBookLookupRequest.create( | ||||||
| itemId = this.itemId!!, | ||||||
| itemIdType = this.itemIdType ?: "ISBN", | ||||||
| optResult = this.optResult | ||||||
| ) | ||||||
| } | ||||||
| fun validIsbn(): String = isbn!! | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 안전하지 않은 non-null assertion 사용
더 안전한 방식으로 구현하는 것을 권장합니다: - fun validIsbn(): String = isbn!!
+ fun validIsbn(): String = isbn ?: throw IllegalStateException("ISBN이 제공되지 않았습니다")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| companion object { | ||||||
| fun of(isbn: String?, optResult: List<String>? = null): BookDetailRequest { | ||||||
| fun from( | ||||||
| isbn: String?, | ||||||
| ): BookDetailRequest { | ||||||
| return BookDetailRequest( | ||||||
| itemId = isbn, | ||||||
| itemIdType = "ISBN", | ||||||
| optResult = optResult | ||||||
| isbn = isbn, | ||||||
| ) | ||||||
| } | ||||||
|
Comment on lines
+31
to
37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Factory 메서드의 입력 검증 부재
입력 검증을 추가하는 것을 권장합니다: companion object {
fun from(
isbn: String?,
): BookDetailRequest {
+ requireNotNull(isbn) { "ISBN은 필수입니다" }
+ require(isbn.matches(Regex(RegexUtils.ISBN13_PATTERN))) { "유효한 13자리 ISBN 형식이 아닙니다" }
return BookDetailRequest(
isbn = isbn,
)
}
}🤖 Prompt for AI Agents |
||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,73 @@ | ||
| package org.yapp.apis.book.dto.request | ||
|
|
||
| import org.yapp.infra.external.aladin.dto.AladinBookSearchRequest | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import jakarta.validation.constraints.Max | ||
| import jakarta.validation.constraints.Min | ||
| import jakarta.validation.constraints.NotBlank | ||
|
|
||
| @Schema( | ||
| title = "책 검색 요청", | ||
| description = "알라딘 API를 통한 책 검색 요청 정보" | ||
| ) | ||
| data class BookSearchRequest private constructor( | ||
| @field:NotBlank(message = "검색어는 필수입니다.") | ||
| @Schema( | ||
| description = "검색할 키워드 (제목, 저자, 출판사 등)", | ||
| example = "해리포터", | ||
| required = true | ||
| ) | ||
| val query: String? = null, | ||
|
|
||
| @Schema( | ||
| description = "검색 유형", | ||
| example = "Title", | ||
| allowableValues = ["Title", "Author", "Publisher", "Keyword"], | ||
| defaultValue = "Keyword" | ||
| ) | ||
| val queryType: String? = null, | ||
|
|
||
| @Schema( | ||
| description = "검색 대상", | ||
| example = "Book", | ||
| allowableValues = ["Book", "Foreign", "Music", "DVD"], | ||
| defaultValue = "Book" | ||
| ) | ||
| val searchTarget: String? = null, | ||
|
|
||
| @field:Min(value = 1, message = "최대 결과 수는 1 이상이어야 합니다.") | ||
| @field:Max(value = 100, message = "최대 결과 수는 100 이하여야 합니다.") | ||
| @Schema( | ||
| description = "한 번에 가져올 최대 결과 수 (1-100)", | ||
| example = "10", | ||
| minimum = "1", | ||
| maximum = "100", | ||
| defaultValue = "10" | ||
| ) | ||
| val maxResults: Int? = null, | ||
|
|
||
| @field:Min(value = 1, message = "시작 인덱스는 1 이상이어야 합니다.") | ||
| @Schema( | ||
| description = "검색 시작 인덱스 (페이징)", | ||
| example = "1", | ||
| minimum = "1", | ||
| defaultValue = "1" | ||
| ) | ||
| val start: Int? = null, | ||
|
|
||
| @Schema( | ||
| description = "정렬 방식", | ||
| example = "Accuracy", | ||
| allowableValues = ["Accuracy", "PublishTime", "Title", "SalesPoint"], | ||
| defaultValue = "Accuracy" | ||
| ) | ||
| val sort: String? = null, | ||
| val cover: String? = null, | ||
|
|
||
| @Schema( | ||
| description = "카테고리 ID (0: 전체)", | ||
| example = "0", | ||
| defaultValue = "0" | ||
| ) | ||
| val categoryId: Int? = null | ||
| ) { | ||
|
|
||
| fun validQuery(): String = query!! | ||
| fun toAladinRequest(): AladinBookSearchRequest { | ||
|
|
||
| return AladinBookSearchRequest.create( | ||
| query = this.validQuery(), | ||
| queryType = this.queryType, | ||
| searchTarget = this.searchTarget, | ||
| maxResults = this.maxResults, | ||
| start = this.start, | ||
| sort = this.sort, | ||
| cover = this.cover, | ||
| categoryId = this.categoryId | ||
| ) | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.