Skip to content

Commit 91462f8

Browse files
authored
Merge pull request #135 from YAPP-Github/BOOK-250-fix/#134
fix: 도서 검색 DTO 변경사항에 따른 LastPage 로직 수정 및 빈 ISBN 대응 로직 추가
2 parents 19cc8fc + a80f2f5 commit 91462f8

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

build-logic/src/main/kotlin/com/ninecraft/booket/convention/ApplicationConstants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ internal object ApplicationConstants {
66
const val MIN_SDK = 28
77
const val TARGET_SDK = 35
88
const val COMPILE_SDK = 35
9-
const val VERSION_CODE = 1
9+
const val VERSION_CODE = 3
1010
const val VERSION_NAME = "1.0.0"
1111
const val JAVA_VERSION_INT = 17
1212
val javaVersion = JavaVersion.VERSION_17

core/data/impl/src/main/kotlin/com/ninecraft/booket/core/data/impl/mapper/ResponseToModel.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ internal fun BookSearchResponse.toModel(): BookSearchModel {
5454
return BookSearchModel(
5555
version = version,
5656
title = title,
57-
link = link,
5857
pubDate = pubDate,
5958
totalResults = totalResults,
6059
startIndex = startIndex,
6160
itemsPerPage = itemsPerPage,
6261
query = query,
6362
searchCategoryId = searchCategoryId,
6463
searchCategoryName = searchCategoryName,
64+
lastPage = lastPage,
6565
books = books.map { it.toModel() },
6666
)
6767
}
@@ -73,7 +73,9 @@ internal fun BookSummary.toModel(): BookSummaryModel {
7373
author = author,
7474
publisher = publisher,
7575
coverImageUrl = coverImageUrl,
76+
link = link,
7677
userBookStatus = userBookStatus,
78+
key = "$title-$isbn13",
7779
)
7880
}
7981

core/model/src/main/kotlin/com/ninecraft/booket/core/model/BookSearchModel.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import androidx.compose.runtime.Stable
66
data class BookSearchModel(
77
val version: String = "",
88
val title: String = "",
9-
val link: String = "",
109
val pubDate: String = "",
1110
val totalResults: Int = 0,
1211
val startIndex: Int = 0,
1312
val itemsPerPage: Int = 0,
1413
val query: String = "",
1514
val searchCategoryId: Int = 0,
1615
val searchCategoryName: String = "",
16+
val lastPage: Boolean = false,
1717
val books: List<BookSummaryModel> = emptyList(),
1818
)
1919

@@ -24,5 +24,7 @@ data class BookSummaryModel(
2424
val author: String = "",
2525
val publisher: String = "",
2626
val coverImageUrl: String = "",
27+
val link: String = "",
2728
val userBookStatus: String = "",
29+
val key: String = "",
2830
)

core/network/src/main/kotlin/com/ninecraft/booket/core/network/response/BookSearchResponse.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ data class BookSearchResponse(
99
val version: String,
1010
@SerialName("title")
1111
val title: String,
12-
@SerialName("link")
13-
val link: String,
1412
@SerialName("pubDate")
1513
val pubDate: String,
1614
@SerialName("totalResults")
@@ -25,6 +23,8 @@ data class BookSearchResponse(
2523
val searchCategoryId: Int,
2624
@SerialName("searchCategoryName")
2725
val searchCategoryName: String,
26+
@SerialName("lastPage")
27+
val lastPage: Boolean,
2828
@SerialName("books")
2929
val books: List<BookSummary>,
3030
)
@@ -41,6 +41,8 @@ data class BookSummary(
4141
val publisher: String,
4242
@SerialName("coverImageUrl")
4343
val coverImageUrl: String,
44+
@SerialName("link")
45+
val link: String,
4446
@SerialName("userBookStatus")
4547
val userBookStatus: String,
4648
)

feature/search/src/main/kotlin/com/ninecraft/booket/feature/search/book/BookSearchPresenter.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class BookSearchPresenter @AssistedInject constructor(
4040
private val repository: BookRepository,
4141
) : Presenter<BookSearchUiState> {
4242
companion object {
43-
private const val PAGE_SIZE = 20
4443
private const val START_INDEX = 1
4544
}
4645

@@ -80,7 +79,7 @@ class BookSearchPresenter @AssistedInject constructor(
8079
}
8180

8281
currentStartIndex = startIndex
83-
isLastPage = result.books.size < PAGE_SIZE
82+
isLastPage = result.lastPage
8483

8584
if (startIndex == START_INDEX) {
8685
uiState = UiState.Success
@@ -185,7 +184,12 @@ class BookSearchPresenter @AssistedInject constructor(
185184

186185
is BookSearchUiEvent.OnBookClick -> {
187186
selectedBookIsbn = event.isbn13
188-
isBookRegisterBottomSheetVisible = true
187+
188+
if (selectedBookIsbn.isEmpty()) {
189+
sideEffect = BookSearchSideEffect.ShowToast("isbn이 없는 도서는 등록할 수 없습니다")
190+
} else {
191+
isBookRegisterBottomSheetVisible = true
192+
}
189193
}
190194

191195
is BookSearchUiEvent.OnBookRegisterBottomSheetDismiss -> {

feature/search/src/main/kotlin/com/ninecraft/booket/feature/search/book/BookSearchUi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ internal fun SearchContent(
222222
) {
223223
items(
224224
count = state.books.size,
225-
key = { index -> state.books[index].isbn13 },
225+
key = { index -> state.books[index].key },
226226
) { index ->
227227
Column {
228228
BookItem(

0 commit comments

Comments
 (0)