Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/#120-scoop-po…
Browse files Browse the repository at this point in the history
…st-api
  • Loading branch information
Roel4990 committed Jan 22, 2025
2 parents 22acdff + 13bf9e0 commit 372c8ba
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package com.spoony.spoony.data.datasource

import com.spoony.spoony.data.dto.base.BaseResponse
import com.spoony.spoony.data.dto.response.PlaceCheckResponseDto
import com.spoony.spoony.data.dto.response.SearchPlaceResponseDto

interface PlaceDataSource {
suspend fun getPlaces(query: String, display: Int): BaseResponse<SearchPlaceResponseDto>

suspend fun checkDuplicatePlace(
userId: Long,
latitude: Double,
longitude: Double
): BaseResponse<PlaceCheckResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.spoony.spoony.data.datasourceimpl

import com.spoony.spoony.data.datasource.PlaceDataSource
import com.spoony.spoony.data.dto.base.BaseResponse
import com.spoony.spoony.data.dto.request.PlaceCheckRequestDto
import com.spoony.spoony.data.dto.response.PlaceCheckResponseDto
import com.spoony.spoony.data.dto.response.SearchPlaceResponseDto
import com.spoony.spoony.data.service.PlaceService
import javax.inject.Inject
Expand All @@ -14,4 +16,17 @@ class PlaceDataSourceImpl @Inject constructor(
display: Int
): BaseResponse<SearchPlaceResponseDto> =
placeService.getPlaces(query, display)

override suspend fun checkDuplicatePlace(
userId: Long,
latitude: Double,
longitude: Double
): BaseResponse<PlaceCheckResponseDto> =
placeService.postDuplicatePlace(
PlaceCheckRequestDto(
userId = userId,
latitude = latitude,
longitude = longitude
)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.spoony.spoony.data.dto.request

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class PlaceCheckRequestDto(
@SerialName("userId")
val userId: Long,
@SerialName("latitude")
val latitude: Double,
@SerialName("longitude")
val longitude: Double
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.spoony.spoony.data.dto.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class PlaceCheckResponseDto(
@SerialName("duplicate")
val idDuplicated: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class RegisterRepositoryImpl @Inject constructor(
latitude: Double,
longitude: Double
): Result<Boolean> = runCatching {
latitude == 35.8703 && longitude == 128.5978
placeDataSource.checkDuplicatePlace(userId, latitude, longitude).data!!.idDuplicated
}

override suspend fun registerPost(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.spoony.spoony.data.service

import com.spoony.spoony.data.dto.base.BaseResponse
import com.spoony.spoony.data.dto.request.PlaceCheckRequestDto
import com.spoony.spoony.data.dto.response.PlaceCheckResponseDto
import com.spoony.spoony.data.dto.response.SearchPlaceResponseDto
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

interface PlaceService {
Expand All @@ -11,4 +15,9 @@ interface PlaceService {
@Query("query") query: String,
@Query("display") display: Int = 5
): BaseResponse<SearchPlaceResponseDto>

@POST("api/v1/place/check")
suspend fun postDuplicatePlace(
@Body request: PlaceCheckRequestDto
): BaseResponse<PlaceCheckResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ fun CategoryEntity.toPresentation(): Category =
categoryId = categoryId,
categoryName = categoryName,
iconUrlSelected = iconUrl,
iconUrlNotSelected = unSelectedIconUrl ?: iconUrl
iconUrlNotSelected = unSelectedIconUrl ?: ""
)

fun PlaceEntity.toPresentation(): Place =
Expand Down

0 comments on commit 372c8ba

Please sign in to comment.