Skip to content

Commit

Permalink
[feat/#104] 열만 입력, (휠체어석) 번호만 입력 추가로 인한 DTO 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
minju1459 committed Aug 21, 2024
1 parent e5e3e96 commit 0380462
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ interface SeatReviewDataSource {

suspend fun postSeatReviewData(
blockId: Int,
seatNumber: Int,
requestSeatReviewDto: RequestSeatReviewDto,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ class SeatReviewDataSourceImpl @Inject constructor(

override suspend fun postSeatReviewData(
blockId: Int,
seatNumber: Int,
requestSeatReviewDto: RequestSeatReviewDto,
) {
return seatReviewService.postSeatReview(
blockId,
seatNumber,
requestSeatReviewDto,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@ import kotlinx.serialization.Serializable

@Serializable
data class RequestSeatReviewDto(
@SerialName("rowNumber")
val rowNumber: Int?,
@SerialName("seatNumber")
val seatNumber: Int?,
@SerialName("images")
val images: List<String>,
@SerialName("dateTime")
val dateTime: String,
@SerialName("good")
val good: List<String>,
@SerialName("bad")
val bad: List<String>,
@SerialName("content")
val content: String?,
@SerialName("dateTime")
val dateTime: String,
)

fun RequestSeatReview.toSeatReview() = RequestSeatReviewDto(
rowNumber = rowNumber,
seatNumber = seatNumber,
images = images,
dateTime = dateTime,
good = good,
bad = bad,
content = content,
dateTime = dateTime,
)
3 changes: 1 addition & 2 deletions data/src/main/java/com/dpm/data/remote/SeatReviewService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ interface SeatReviewService {
@Body image: RequestBody,
)

@POST("/api/v1/blocks/{blockId}/seats/{seatNumber}/reviews")
@POST("/api/v1/blocks/{blockId}/reviews")
suspend fun postSeatReview(
@Path("blockId") blockId: Int,
@Path("seatNumber") seatNumber: Int,
@Body requestPostSignupDto: RequestSeatReviewDto,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,11 @@ class SeatReviewRepositoryImpl @Inject constructor(

override suspend fun postSeatReview(
blockId: Int,
seatNumber: Int,
seatReviewInfo: RequestSeatReview,
): Result<Unit> {
return runCatching {
seatReviewDataSource.postSeatReviewData(
blockId,
seatNumber,
seatReviewInfo.toSeatReview(),
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.dpm.domain.entity.request.seatreview

data class RequestSeatReview(
val rowNumber: Int?,
val seatNumber: Int?,
val images: List<String>,
val dateTime: String,
val good: List<String>,
val bad: List<String>,
val content: String?,
val dateTime: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ interface SeatReviewRepository {
): Result<Unit>

suspend fun postSeatReview(
seatId: Int,
seatNumber: Int,
blockId: Int,
seatReviewInfo: RequestSeatReview,
): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,13 @@ class ReviewViewModel @Inject constructor(
fun postSeatReview() {
viewModelScope.launch {
val requestSeatReview = RequestSeatReview(
rowNumber = _selectedColumn.value.toIntOrNull(),
seatNumber = _selectedNumber.value.toIntOrNull(),
images = _preSignedUrlImages.value,
dateTime = _selectedDate.value,
good = _selectedGoodReview.value,
bad = _selectedBadReview.value,
content = detailReviewText.value,
dateTime = _selectedDate.value,
)
Timber.d("Selected Images: ${_preSignedUrlImages.value}")
Timber.d("Selected Date: ${_selectedDate.value}")
Expand All @@ -347,12 +349,11 @@ class ReviewViewModel @Inject constructor(
Timber.d("Detail Review Text: ${detailReviewText.value}")
Timber.d("Selected Stadium ID: ${_selectedStadiumId.value}")
Timber.d("Selected Block ID: ${_selectedBlockId.value}")
Timber.d("Selected seatColumn: ${selectedColumn.value}")
Timber.d("Selected seatNumber: ${selectedNumber.value}")
Timber.d("Selected Number: ${selectedNumber.value}")
_postReviewState.value = UiState.Loading
seatReviewRepository.postSeatReview(
_selectedBlockId.value,
selectedNumber.value.toInt(),
requestSeatReview,
)
.onSuccess {
Expand All @@ -361,7 +362,15 @@ class ReviewViewModel @Inject constructor(
}
.onFailure { t ->
if (t is HttpException) {
Timber.e("POST REVIEW FAILURE : $t")
val errorCode = t.code() // HTTP 상태 코드 (403)
val errorBody = t.response()?.errorBody()?.string() // 응답 본문
val errorHeaders = t.response()?.headers()?.toString() // 응답 헤더

Timber.e("POST REVIEW FAILURE: HTTP $errorCode")
Timber.e("Error Body: $errorBody")
Timber.e("Error Headers: $errorHeaders")
} else {
Timber.e("POST REVIEW FAILURE: $t")
}
}
}
Expand Down

0 comments on commit 0380462

Please sign in to comment.