-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 알라딘 도서 검색 ISBN 변환 및 유효성 검증 로직 개선 #77
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
Conversation
WalkthroughISBN-10 및 ISBN-13 유효성 검사와 변환 로직이 리팩토링되었습니다. Aladin API 검색 결과에서 ISBN-13이 'K'로 시작하는 도서를 제외하는 필터링 로직이 추가되었습니다. 일부 데이터 클래스의 생성자 공개 범위가 internal에서 public으로 변경되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant AladinBookQueryService
participant AladinAPI
participant IsbnConverter
participant IsbnValidator
Client->>AladinBookQueryService: searchBooks(query)
AladinBookQueryService->>AladinAPI: fetch book list
AladinAPI-->>AladinBookQueryService: AladinSearchResponse
loop For each item in response
AladinBookQueryService->>IsbnConverter: Convert ISBN if needed
IsbnConverter-->>AladinBookQueryService: isbn13
AladinBookQueryService->>IsbnValidator: isValidIsbn(isbn13)
IsbnValidator-->>AladinBookQueryService: true/false
alt isbn13 startsWith "K"
AladinBookQueryService-->>AladinBookQueryService: exclude item
else
AladinBookQueryService-->>AladinBookQueryService: include item
end
end
AladinBookQueryService-->>Client: BookSearchResponse (filtered)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Suggested reviewers
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🔇 Additional comments (3)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (6)
apis/src/main/kotlin/org/yapp/apis/auth/util/IsbnConverter.kt(1 hunks)apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookDetailResponse.kt(2 hunks)apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt(4 hunks)apis/src/main/kotlin/org/yapp/apis/book/service/AladinBookQueryService.kt(2 hunks)global-utils/src/main/kotlin/org/yapp/globalutils/validator/IsbnValidator.kt(1 hunks)infra/src/main/kotlin/org/yapp/infra/external/aladin/response/AladinSearchResponse.kt(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-validation
🔇 Additional comments (12)
infra/src/main/kotlin/org/yapp/infra/external/aladin/response/AladinSearchResponse.kt (1)
8-8: 생성자 가시성 변경이 적절합니다.
internal한정자 제거로 인해 다른 모듈에서 이 클래스들의 인스턴스를 생성할 수 있게 되었습니다. AladinBookQueryService에서 필터링된 응답 객체를 생성하기 위해 필요한 변경사항으로 보입니다.Also applies to: 23-23
global-utils/src/main/kotlin/org/yapp/globalutils/validator/IsbnValidator.kt (2)
3-3: ISBN 패턴 분리로 검증 정확도가 향상되었습니다.RegexUtils에서 가져온 별도의 ISBN-10과 ISBN-13 패턴을 사용하여 더 정확한 검증이 가능해졌습니다. 이전의 단순한 길이 기반 검증보다 개선된 접근법입니다.
Also applies to: 6-7
10-10: OR 연산을 통한 유연한 ISBN 검증 로직이 적절합니다.ISBN-10과 ISBN-13 두 패턴 중 하나라도 매칭되면 유효한 것으로 판단하는 로직이 올바릅니다.
apis/src/main/kotlin/org/yapp/apis/auth/util/IsbnConverter.kt (1)
14-15: Kotlin 관용구를 활용한 깔끔한 검증 로직 리팩토링입니다.
takeIf를 사용하여 길이와 패턴 검증을 체인으로 연결한 것이 이전의 여러 조건문보다 간결하고 읽기 쉽습니다. 기능적 동작은 동일하게 유지되면서 코드 품질이 개선되었습니다.apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookDetailResponse.kt (2)
34-36: ISBN 처리 로직의 중앙화와 방어적 프로그래밍이 잘 적용되었습니다.ISBN-13을 우선 사용하고, 없으면 ISBN-10을 변환하는 폴백 로직이 명확합니다. 둘 다 사용할 수 없을 때 예외를 발생시키는 것도 적절합니다.
46-46: 계산된 변수 사용으로 가독성이 향상되었습니다.인라인 로직 대신 미리 계산된
isbn13변수를 사용하여 코드가 더 깔끔해졌습니다.apis/src/main/kotlin/org/yapp/apis/book/service/AladinBookQueryService.kt (3)
13-14: 필요한 유틸리티 import가 적절합니다.ISBN 변환과 검증을 위한 유틸리티들이 올바르게 import되었습니다.
55-67: 필터링된 응답 객체 생성 로직이 적절합니다.원본 응답의 모든 필드를 유지하면서 필터링된 아이템과 업데이트된 totalResults만 변경한 것이 올바릅니다.
69-69: 필터링된 응답 사용이 적절합니다.변환 로직에 필터링된 응답을 전달하는 것이 맞습니다.
apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt (3)
5-5: Import 추가 승인ISBN 변환 로직을 위한
IsbnConverterimport 추가가 적절합니다.
38-47: Null 안전성 개선 승인
mapNotNull사용과emptyList()기본값 제공으로 null 안전성이 크게 개선되었습니다.BookSummary.of가 nullable을 반환하므로 이 처리가 적절합니다.
80-80: finalIsbn 사용 승인계산된
finalIsbn값을 사용하여 일관성 있는 ISBN 할당이 이루어졌습니다.
| ): BookSummary? { | ||
| require(!title.isNullOrBlank()) { "Title is required" } | ||
|
|
||
| val finalIsbn = isbn13?.takeIf { it.isNotBlank() } | ||
| ?: isbn?.takeIf { it.isNotBlank() }?.let { IsbnConverter.toIsbn13(it) } | ||
| ?: return null | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
ISBN 처리 로직 개선 승인 및 K로 시작하는 ISBN 필터링 누락
ISBN 처리 로직이 크게 개선되었습니다:
- nullable 반환 타입으로 변경하여 유효하지 않은 경우 적절히 처리
- ISBN-13 우선, 그 다음 ISBN-10에서 변환하는 로직이 합리적
하지만 PR 목적 중 하나인 'K로 시작하는 ISBN 제외' 로직이 누락되었습니다.
다음 스크립트로 K로 시작하는 ISBN 필터링 로직이 구현되어 있는지 확인해보겠습니다:
또한 IsbnConverter.toIsbn13() 메서드의 오류 처리 방식을 확인해보겠습니다:
🏁 Script executed:
#!/bin/bash
# K로 시작하는 ISBN 필터링 로직 확인
rg -A 5 -B 5 "startsWith.*K|K.*startsWith" --type kotlinLength of output: 58
🏁 Script executed:
#!/bin/bash
# IsbnConverter.toIsbn13 메서드 구현 확인
ast-grep --pattern $'fun toIsbn13($_) {
$$$
}'Length of output: 49
다음 스크립트들로 IsbnConverter 구현 위치와 toIsbn13 메서드 시그니처 및 본문을 확인해주세요:
🏁 Script executed:
#!/bin/bash
# 1. IsbnConverter 클래스/객체 파일 경로 찾기
rg -l "IsbnConverter" --type kotlinLength of output: 321
🏁 Script executed:
#!/bin/bash
# 2. toIsbn13 메서드 정의 위치 및 시그니처 확인
rg -n "fun toIsbn13" --type kotlinLength of output: 146
🏁 Script executed:
#!/bin/bash
# 3. IsbnConverter 파일 내용(최초 200줄) 출력
file=$(rg -l "IsbnConverter" --type kotlin | head -n1)
if [ -n "$file" ]; then
sed -n '1,200p' "$file"
fiLength of output: 4192
다음 스크립트로 IsbnConverter.kt 파일의 toIsbn13 구현을 확인해주세요:
🏁 Script executed:
#!/bin/bash
# IsbnConverter.kt 전체 내용(최초 200줄) 출력
sed -n '1,200p' apis/src/main/kotlin/org/yapp/apis/auth/util/IsbnConverter.ktLength of output: 1001
K로 시작하는 ISBN 필터링 로직 추가 필요
BookSearchResponse.kt의 BookSummary.of(Lines 72–78)에서 ISBN 변환 및 null 처리 로직은 적절히 구현되었으나, “K로 시작하는 ISBN 제외” 요구사항이 반영되어 있지 않습니다.
또한 IsbnConverter.toIsbn13()는 유효하지 않은 ISBN10 입력 시 null을 반환하므로 예외 발생 우려는 없습니다.
수정 제안:
finalIsbn결정 직후에 K로 시작하는지 확인하고, 해당 경우null반환- 또는
takeIf체인에!it.startsWith("K")조건을 추가
예시 diff:
val finalIsbn = isbn13?.takeIf { it.isNotBlank() }
?: isbn?.takeIf { it.isNotBlank() }?.let { IsbnConverter.toIsbn13(it) }
?: return null
+ // K로 시작하는 ISBN 제외
+ if (finalIsbn.startsWith("K")) return null- 파일: apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt
- 위치:
BookSummary.of내부,finalIsbn할당 직후
🤖 Prompt for AI Agents
In apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt
around lines 72 to 78, the current logic for determining finalIsbn does not
exclude ISBNs starting with "K" as required. To fix this, after computing
finalIsbn, add a check to return null if finalIsbn starts with "K".
Alternatively, include a condition in the takeIf chain to ensure the ISBN does
not start with "K". This will properly filter out unwanted ISBNs while
preserving existing null handling.
apis/src/main/kotlin/org/yapp/apis/book/service/AladinBookQueryService.kt
Show resolved
Hide resolved
|


🔗 관련 이슈
📘 작업 유형
📙 작업 내역
toIsbn13)BookDetailResponse,BookSearchResponse내 ISBN 처리 로직 정리 및 예외 방어 처리 추가BookSearchResponse변환 시 유효한 ISBN만 필터링IsbnValidator유틸 클래스 도입하여 유효성 검사 적용🧪 테스트 내역
🎨 스크린샷 또는 시연 영상 (선택)
✅ PR 체크리스트
💬 추가 설명 or 리뷰 포인트
isbn13이 존재하지 않으면isbn10을 변환하여 사용합니다.BookSummary가null인 경우도 필터링됩니다.Summary by CodeRabbit