-
Notifications
You must be signed in to change notification settings - Fork 1
feat: userBookStatus에 등록 전 enum 추가 #65
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
📝 WalkthroughWalkthrough
Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant BookUseCase
participant BookSearchResponse
User->>BookUseCase: searchBooks()
BookUseCase->>BookSearchResponse: BookSearchResponse.fromAladinItem()
BookUseCase->>BookSearchResponse: from(updatedBooks)
BookUseCase-->>User: BookSearchResponse (with updated userBookStatus)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
Possibly related PRs
Suggested reviewers
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ 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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. 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: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt(2 hunks)apis/src/main/kotlin/org/yapp/apis/book/usecase/BookUseCase.kt(1 hunks)domain/src/main/kotlin/org/yapp/domain/userbook/BookStatus.kt(1 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 (3)
domain/src/main/kotlin/org/yapp/domain/userbook/BookStatus.kt (1)
4-4: enum 순서 변경 안전 확인BookStatus enum은 데이터베이스에 문자열(EnumType.STRING)로 저장되며, 코드 전반에서
ordinal()호출이나 ordinal 기반 비교를 찾을 수 없었습니다.
따라서BEFORE_REGISTRATION를 맨 앞에 추가하더라도 기존 데이터나 로직에 영향이 없습니다.
- infra/src/main/kotlin/org/yapp/infra/userbook/entity/UserBookEntity.kt:
@Enumerated(EnumType.STRING)사용 확인apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt (1)
81-81: 기본 상태 변경이 적절함
BEFORE_READING에서BEFORE_REGISTRATION으로 기본 상태를 변경한 것이 논리적으로 적절합니다. 사용자가 아직 책을 등록하지 않은 초기 상태를 정확히 표현합니다.apis/src/main/kotlin/org/yapp/apis/book/usecase/BookUseCase.kt (1)
47-53: 함수형 접근으로의 우수한 리팩토링mutable한
forEach루프를 immutable한map연산으로 리팩토링한 것이 훌륭합니다. 이 변경으로 다음과 같은 이점을 얻었습니다:
- 불변성 보장으로 사이드 이펙트 제거
- 함수형 프로그래밍 스타일 적용
let을 사용한 null-safe 처리로 안전성 향상- 새로운
from메서드와 잘 통합됨
| fun from(updatedBooks: List<BookSummary>): BookSearchResponse { | ||
| return BookSearchResponse( | ||
| version = this.version, | ||
| title = this.title, | ||
| link = this.link, | ||
| pubDate = this.pubDate, | ||
| totalResults = this.totalResults, | ||
| startIndex = this.startIndex, | ||
| itemsPerPage = this.itemsPerPage, | ||
| query = this.query, | ||
| searchCategoryId = this.searchCategoryId, | ||
| searchCategoryName = this.searchCategoryName, | ||
| books = updatedBooks | ||
| ) | ||
| } |
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.
🧹 Nitpick (assertive)
data class의 copy() 메서드 활용으로 간소화 가능
새로운 from 메서드의 구현은 올바르지만, data class의 내장 copy() 메서드를 사용하면 더 간결하게 작성할 수 있습니다.
다음과 같이 리팩토링할 수 있습니다:
- fun from(updatedBooks: List<BookSummary>): BookSearchResponse {
- return BookSearchResponse(
- version = this.version,
- title = this.title,
- link = this.link,
- pubDate = this.pubDate,
- totalResults = this.totalResults,
- startIndex = this.startIndex,
- itemsPerPage = this.itemsPerPage,
- query = this.query,
- searchCategoryId = this.searchCategoryId,
- searchCategoryName = this.searchCategoryName,
- books = updatedBooks
- )
- }
+ fun from(updatedBooks: List<BookSummary>): BookSearchResponse {
+ return this.copy(books = updatedBooks)
+ }🤖 Prompt for AI Agents
In apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt
around lines 22 to 36, the from() method manually copies all properties to
create a new instance. Refactor this method to use the data class's built-in
copy() function with the updatedBooks list as the only changed property, which
simplifies the code and reduces redundancy.


🔗 관련 이슈
📘 작업 유형
📙 작업 내역
BookSearchResponse에from(updatedBooks: List<BookSummary>)함수 추가BookStatus)를 반영하도록BookUseCase수정BEFORE_READING→BEFORE_REGISTRATION으로 변경BookStatusenum에BEFORE_REGISTRATION상태 추가🧪 테스트 내역
🎨 스크린샷 또는 시연 영상 (선택)
(해당 사항 없음)
✅ PR 체크리스트
💬 추가 설명 or 리뷰 포인트 (선택)
BookSearchResponse에 기존 인스턴스를 기반으로 새로운 리스트를 반영하는from()메서드를 도입해 불변성을 유지했습니다.BEFORE_REGISTRATION으로 초기화되도록 처리했습니다.Summary by CodeRabbit
신규 기능
버그 수정
기타