From 5a08f445f500149ebaee323b462ee5984d2344ff Mon Sep 17 00:00:00 2001 From: krrong Date: Thu, 5 Oct 2023 16:58:42 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=9E=A5=EC=86=8C=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20api=20=EC=88=98=EC=A0=95=20(#369)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 장소 등록을 검수할 수 있도록 검수중으로 등록한다 * refactor: 변경된 API 명세 반영 * refactor: string 변경 * feat: 장소등록 성공시 토스트 메시지를 띄워줌 --- .../com/now/naaga/data/mapper/PlaceMapper.kt | 11 ++++++++++ .../now/naaga/data/remote/dto/PostPlaceDto.kt | 20 +++++++++++++++++++ .../remote/retrofit/service/PlaceService.kt | 5 +++-- .../presentation/upload/UploadActivity.kt | 1 + android/app/src/main/res/values/strings.xml | 3 ++- 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 android/app/src/main/java/com/now/naaga/data/remote/dto/PostPlaceDto.kt diff --git a/android/app/src/main/java/com/now/naaga/data/mapper/PlaceMapper.kt b/android/app/src/main/java/com/now/naaga/data/mapper/PlaceMapper.kt index 7f10ab138..c254fa327 100644 --- a/android/app/src/main/java/com/now/naaga/data/mapper/PlaceMapper.kt +++ b/android/app/src/main/java/com/now/naaga/data/mapper/PlaceMapper.kt @@ -2,6 +2,7 @@ package com.now.naaga.data.mapper import com.now.domain.model.Place import com.now.naaga.data.remote.dto.PlaceDto +import com.now.naaga.data.remote.dto.PostPlaceDto fun Place.toDto(): PlaceDto { return PlaceDto( @@ -22,3 +23,13 @@ fun PlaceDto.toDomain(): Place { description = description, ) } + +fun PostPlaceDto.toDomain(): Place { + return Place( + id = id, + name = name, + coordinate = coordinate.toDomain(), + image = imageUrl, + description = description, + ) +} diff --git a/android/app/src/main/java/com/now/naaga/data/remote/dto/PostPlaceDto.kt b/android/app/src/main/java/com/now/naaga/data/remote/dto/PostPlaceDto.kt new file mode 100644 index 000000000..149455438 --- /dev/null +++ b/android/app/src/main/java/com/now/naaga/data/remote/dto/PostPlaceDto.kt @@ -0,0 +1,20 @@ +package com.now.naaga.data.remote.dto + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class PostPlaceDto( + @SerialName("id") + val id: Long, + @SerialName("name") + val name: String, + @SerialName("coordinate") + val coordinate: CoordinateDto, + @SerialName("imageUrl") + val imageUrl: String, + @SerialName("description") + val description: String, + @SerialName("registeredPlayerId") + val registeredPlayerId: Long, +) diff --git a/android/app/src/main/java/com/now/naaga/data/remote/retrofit/service/PlaceService.kt b/android/app/src/main/java/com/now/naaga/data/remote/retrofit/service/PlaceService.kt index e725ee4d1..0fb325c3b 100644 --- a/android/app/src/main/java/com/now/naaga/data/remote/retrofit/service/PlaceService.kt +++ b/android/app/src/main/java/com/now/naaga/data/remote/retrofit/service/PlaceService.kt @@ -1,6 +1,7 @@ package com.now.naaga.data.remote.retrofit.service import com.now.naaga.data.remote.dto.PlaceDto +import com.now.naaga.data.remote.dto.PostPlaceDto import okhttp3.MultipartBody import okhttp3.RequestBody import retrofit2.Response @@ -25,9 +26,9 @@ interface PlaceService { ): Response @Multipart - @POST("/places") + @POST("/temporary-places") suspend fun registerPlace( @PartMap postData: HashMap, @Part imageFile: MultipartBody.Part, - ): Response + ): Response } diff --git a/android/app/src/main/java/com/now/naaga/presentation/upload/UploadActivity.kt b/android/app/src/main/java/com/now/naaga/presentation/upload/UploadActivity.kt index bbea346de..ee90d938e 100644 --- a/android/app/src/main/java/com/now/naaga/presentation/upload/UploadActivity.kt +++ b/android/app/src/main/java/com/now/naaga/presentation/upload/UploadActivity.kt @@ -92,6 +92,7 @@ class UploadActivity : AppCompatActivity(), AnalyticsDelegate by DefaultAnalytic when (uploadStatus) { UploadStatus.SUCCESS -> { changeVisibility(binding.lottieUploadLoading, View.GONE) + shortToast(getString(R.string.upload_success_submit)) finish() } diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 41af4e61d..77a240773 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -58,8 +58,9 @@ 장소 등록 장소이름 - 이곳에 장소이름을 적어주세요! + 장소이름을 적어주세요! 장소 등록 + 장소등록에 성공했어요!\n반영되기까지 약간의 시간이 필요해요! 장소등록에 실패했어요! 사진을 저장하는데 문제가 생겼어요! 다시 시도해주세요! 근방에 다른 미션장소가 존재해서 추가할 수 없어요!