Skip to content

Commit 0ee57fc

Browse files
authored
feat: userBookStatus에 등록 전 enum 추가 (#65)
* [BOOK-191] feat: domain - 등록 전 상태 값 추가(#60) * [BOOK-191] feat: apis - 등록전 상태값 기능 추가(#60)
1 parent 5542b9c commit 0ee57fc

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ data class BookSearchResponse private constructor(
1919
val searchCategoryName: String?,
2020
val books: List<BookSummary>
2121
) {
22+
fun from(updatedBooks: List<BookSummary>): BookSearchResponse {
23+
return BookSearchResponse(
24+
version = this.version,
25+
title = this.title,
26+
link = this.link,
27+
pubDate = this.pubDate,
28+
totalResults = this.totalResults,
29+
startIndex = this.startIndex,
30+
itemsPerPage = this.itemsPerPage,
31+
query = this.query,
32+
searchCategoryId = this.searchCategoryId,
33+
searchCategoryName = this.searchCategoryName,
34+
books = updatedBooks
35+
)
36+
}
37+
2238
companion object {
2339
fun from(response: AladinSearchResponse): BookSearchResponse {
2440
val books = response.item?.mapNotNull { BookSummary.fromAladinItem(it) } ?: emptyList()
@@ -62,7 +78,7 @@ data class BookSearchResponse private constructor(
6278
author = item.author,
6379
publisher = item.publisher,
6480
coverImageUrl = item.cover,
65-
userBookStatus = BookStatus.BEFORE_READING
81+
userBookStatus = BookStatus.BEFORE_REGISTRATION
6682
)
6783
}
6884
}

apis/src/main/kotlin/org/yapp/apis/book/usecase/BookUseCase.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ class BookUseCase(
4343

4444
val userBooksReponse = userBookService.findAllByUserIdAndBookIsbnIn(UserBooksByIsbnsRequest.of(userId, isbns))
4545
val statusMap = userBooksReponse.associateBy({ it.bookIsbn }, { it.status })
46-
searchResponse.books.forEach { bookSummary ->
46+
47+
val updatedBooks = searchResponse.books.map { bookSummary ->
4748
statusMap[bookSummary.isbn]?.let { status ->
4849
bookSummary.updateStatus(status)
49-
}
50+
} ?: bookSummary
5051
}
51-
return searchResponse
52+
53+
return searchResponse.from(updatedBooks)
5254
}
5355

5456
fun getBookDetail(bookDetailRequest: BookDetailRequest): BookDetailResponse {

domain/src/main/kotlin/org/yapp/domain/userbook/BookStatus.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.yapp.domain.userbook
22

33
enum class BookStatus {
4+
BEFORE_REGISTRATION, // 등록 전
45
BEFORE_READING, // 읽기 전
56
READING, // 읽는 중
67
COMPLETED // 완독

0 commit comments

Comments
 (0)