Skip to content

Commit abd709a

Browse files
committed
[BOOK-212] feat: 도서 상세 API 스펙 변경 반영
1 parent 46ef824 commit abd709a

File tree

14 files changed

+42
-50
lines changed

14 files changed

+42
-50
lines changed

core/common/src/main/kotlin/com/ninecraft/booket/core/common/extensions/String.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,12 @@ fun String.decodeHtmlEntities(): String {
1212
.replace("'", "'")
1313
.replace(" ", " ")
1414
}
15+
16+
fun String.formatPublishYear(): String {
17+
return try {
18+
val year = this.substringBefore("-")
19+
"${year}"
20+
} catch (e: Exception) {
21+
this
22+
}
23+
}

core/data/api/src/main/kotlin/com/ninecraft/booket/core/data/api/repository/BookRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface BookRepository {
1818

1919
suspend fun removeRecentSearch(query: String)
2020

21-
suspend fun getBookDetail(itemId: String): Result<BookDetailModel>
21+
suspend fun getBookDetail(isbn: String): Result<BookDetailModel>
2222

2323
suspend fun upsertBook(
2424
bookIsbn: String,

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,13 @@ internal fun BookDetailResponse.toModel(): BookDetailModel {
7676
author = author,
7777
pubDate = pubDate,
7878
description = description,
79-
isbn = isbn,
8079
isbn13 = isbn13,
81-
itemId = itemId,
82-
priceSales = priceSales,
83-
priceStandard = priceStandard,
8480
mallType = mallType,
85-
stockStatus = stockStatus,
86-
mileage = mileage,
87-
cover = cover,
88-
categoryId = categoryId,
81+
coverImageUrl = coverImageUrl,
8982
categoryName = categoryName,
9083
publisher = publisher,
84+
totalPage = totalPage,
85+
userBookStatus = userBookStatus,
9186
)
9287
}
9388

core/data/impl/src/main/kotlin/com/ninecraft/booket/core/data/impl/repository/DefaultBookRepository.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ internal class DefaultBookRepository @Inject constructor(
3232
dataSource.removeRecentSearch(query)
3333
}
3434

35-
override suspend fun getBookDetail(itemId: String) = runSuspendCatching {
36-
service.getBookDetail(itemId).toModel()
35+
override suspend fun getBookDetail(isbn: String) = runSuspendCatching {
36+
service.getBookDetail(isbn).toModel()
3737
}
3838

3939
override suspend fun upsertBook(bookIsbn: String, bookStatus: String) = runSuspendCatching {

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@ data class BookDetailModel(
1010
val author: String = "",
1111
val pubDate: String = "",
1212
val description: String = "",
13-
val isbn: String = "",
1413
val isbn13: String = "",
15-
val itemId: Long = 0L,
16-
val priceSales: Double = 0.0,
17-
val priceStandard: Double = 0.0,
1814
val mallType: String = "",
19-
val stockStatus: String = "",
20-
val mileage: Int = 0,
21-
val cover: String = "",
15+
val coverImageUrl: String = "",
2216
val categoryId: Int = 0,
2317
val categoryName: String = "",
2418
val publisher: String = "",
19+
val totalPage: Int = 0,
20+
val userBookStatus: String = "",
2521
)

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,18 @@ data class BookDetailResponse(
1717
val pubDate: String,
1818
@SerialName("description")
1919
val description: String,
20-
@SerialName("isbn")
21-
val isbn: String,
2220
@SerialName("isbn13")
2321
val isbn13: String,
24-
@SerialName("itemId")
25-
val itemId: Long,
26-
@SerialName("priceSales")
27-
val priceSales: Double,
28-
@SerialName("priceStandard")
29-
val priceStandard: Double,
3022
@SerialName("mallType")
3123
val mallType: String,
32-
@SerialName("stockStatus")
33-
val stockStatus: String,
34-
@SerialName("mileage")
35-
val mileage: Int,
36-
@SerialName("cover")
37-
val cover: String,
38-
@SerialName("categoryId")
39-
val categoryId: Int,
24+
@SerialName("coverImageUrl")
25+
val coverImageUrl: String,
4026
@SerialName("categoryName")
4127
val categoryName: String,
4228
@SerialName("publisher")
4329
val publisher: String,
30+
@SerialName("totalPage")
31+
val totalPage: Int,
32+
@SerialName("userBookStatus")
33+
val userBookStatus: String,
4434
)

core/network/src/main/kotlin/com/ninecraft/booket/core/network/service/ReedService.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ interface ReedService {
5656

5757
@GET("api/v1/books/detail")
5858
suspend fun getBookDetail(
59-
@Query("itemId") itemId: String,
60-
@Query("itemIdType") itemIdType: String = "ISBN",
61-
@Query("optResult") optResult: String = "BookInfo,Toc,PreviewImg",
59+
@Query("isbn") isbn: String,
6260
): BookDetailResponse
6361

6462
@PUT("api/v1/books/upsert")

feature/detail/src/main/kotlin/com/ninecraft/booket/feature/detail/book/BookDetailPresenter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class BookDetailPresenter @AssistedInject constructor(
8181
scope.launch {
8282
try {
8383
isLoading = true
84-
repository.getBookDetail(screen.bookId)
84+
repository.getBookDetail(screen.isbn)
8585
.onSuccess { result ->
8686
bookDetail = result
8787
}
@@ -128,7 +128,7 @@ class BookDetailPresenter @AssistedInject constructor(
128128
}
129129
}
130130

131-
LaunchedEffect(screen.bookId) {
131+
LaunchedEffect(Unit) {
132132
getSeedsStats()
133133
getBookDetail()
134134
}
@@ -164,7 +164,7 @@ class BookDetailPresenter @AssistedInject constructor(
164164
}
165165

166166
is BookDetailUiEvent.OnBookStatusUpdateButtonClick -> {
167-
upsertBook(screen.bookId, currentBookStatus.value)
167+
upsertBook(screen.isbn, currentBookStatus.value)
168168
}
169169

170170
is BookDetailUiEvent.OnRecordSortBottomSheetDismiss -> {

feature/detail/src/main/kotlin/com/ninecraft/booket/feature/detail/book/BookDetailUi.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ internal fun BookDetailContent(
147147
onClick = {
148148
state.eventSink(BookDetailUiEvent.OnBookStatusButtonClick)
149149
},
150-
text = "읽는 중",
150+
text = stringResource(
151+
BookStatus.fromValue(state.bookDetail.userBookStatus)?.getDisplayNameRes()
152+
?: BookStatus.BEFORE_READING.getDisplayNameRes()
153+
),
151154
sizeStyle = largeButtonStyle,
152155
colorStyle = ReedButtonColorStyle.SECONDARY,
153156
modifier = Modifier.widthIn(min = 98.dp),

feature/detail/src/main/kotlin/com/ninecraft/booket/feature/detail/book/component/BookItem.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import androidx.compose.ui.draw.clip
1717
import androidx.compose.ui.res.painterResource
1818
import androidx.compose.ui.text.style.TextOverflow
1919
import androidx.compose.ui.unit.dp
20+
import com.ninecraft.booket.core.common.extensions.formatPublishYear
2021
import com.ninecraft.booket.core.designsystem.component.NetworkImage
2122
import com.ninecraft.booket.core.designsystem.theme.ReedTheme
2223
import com.ninecraft.booket.core.model.BookDetailModel
@@ -33,7 +34,7 @@ internal fun BookItem(
3334
.padding(horizontal = ReedTheme.spacing.spacing5),
3435
) {
3536
NetworkImage(
36-
imageUrl = bookDetail.cover,
37+
imageUrl = bookDetail.coverImageUrl,
3738
contentDescription = "Book CoverImage",
3839
modifier = Modifier
3940
.padding(end = ReedTheme.spacing.spacing4)
@@ -44,7 +45,7 @@ internal fun BookItem(
4445
)
4546
Column(modifier = Modifier.weight(1f)) {
4647
Text(
47-
text = "여름은 오래 그곳에 남아",
48+
text = bookDetail.title,
4849
color = ReedTheme.colors.contentPrimary,
4950
overflow = TextOverflow.Ellipsis,
5051
maxLines = 2,
@@ -56,7 +57,7 @@ internal fun BookItem(
5657
verticalAlignment = Alignment.CenterVertically,
5758
) {
5859
Text(
59-
text = "미쓰이에 마사시",
60+
text = bookDetail.author,
6061
color = ReedTheme.colors.contentTertiary,
6162
overflow = TextOverflow.Ellipsis,
6263
maxLines = 1,
@@ -71,7 +72,7 @@ internal fun BookItem(
7172
)
7273
Spacer(Modifier.width(ReedTheme.spacing.spacing1))
7374
Text(
74-
text = "비채",
75+
text = bookDetail.publisher,
7576
color = ReedTheme.colors.contentTertiary,
7677
overflow = TextOverflow.Ellipsis,
7778
maxLines = 1,
@@ -81,7 +82,7 @@ internal fun BookItem(
8182
}
8283
Spacer(Modifier.width(ReedTheme.spacing.spacing05))
8384
Text(
84-
text = "2024년",
85+
text = bookDetail.pubDate.formatPublishYear(),
8586
color = ReedTheme.colors.contentTertiary,
8687
overflow = TextOverflow.Ellipsis,
8788
maxLines = 1,

0 commit comments

Comments
 (0)