File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed
apis/src/main/kotlin/org/yapp/apis/book
domain/src/main/kotlin/org/yapp/domain/userbook Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff line change 11package org.yapp.domain.userbook
22
33enum class BookStatus {
4+ BEFORE_REGISTRATION , // 등록 전
45 BEFORE_READING , // 읽기 전
56 READING , // 읽는 중
67 COMPLETED // 완독
You can’t perform that action at this time.
0 commit comments