-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…lace-duplicated-api
- Loading branch information
Showing
11 changed files
with
148 additions
and
42 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/spoony/spoony/data/datasource/PlaceDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.spoony.spoony.data.datasource | ||
|
||
import com.spoony.spoony.data.dto.response.BaseResponse | ||
import com.spoony.spoony.data.dto.response.SearchPlaceData | ||
|
||
interface PlaceDataSource { | ||
suspend fun searchPlace(query: String, display: Int): BaseResponse<SearchPlaceData> | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/spoony/spoony/data/datasourceimpl/PlaceDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.spoony.spoony.data.datasourceimpl | ||
|
||
import com.spoony.spoony.data.datasource.PlaceDataSource | ||
import com.spoony.spoony.data.dto.response.BaseResponse | ||
import com.spoony.spoony.data.dto.response.SearchPlaceData | ||
import com.spoony.spoony.data.service.PlaceService | ||
import javax.inject.Inject | ||
|
||
class PlaceDataSourceImpl @Inject constructor( | ||
private val placeService: PlaceService | ||
) : PlaceDataSource { | ||
override suspend fun searchPlace( | ||
query: String, | ||
display: Int | ||
): BaseResponse<SearchPlaceData> = | ||
placeService.searchPlace(query, display) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/spoony/spoony/data/dto/response/BaseResponseDTO.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.spoony.spoony.data.dto.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class BaseResponse<T>( | ||
@SerialName("success") | ||
val success: Boolean, | ||
@SerialName("error") | ||
val error: ErrorResponse? = null, | ||
@SerialName("data") | ||
val data: T? = null | ||
) | ||
|
||
@Serializable | ||
data class ErrorResponse( | ||
@SerialName("message") | ||
val message: String | ||
) |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/spoony/spoony/data/dto/response/PlaceResponseDTO.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.spoony.spoony.data.dto.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SearchPlaceData( | ||
@SerialName("placeList") | ||
val placeList: List<PlaceDto> | ||
) | ||
|
||
@Serializable | ||
data class PlaceDto( | ||
@SerialName("placeName") | ||
val placeName: String, | ||
@SerialName("placeAddress") | ||
val placeAddress: String, | ||
@SerialName("placeRoadAddress") | ||
val placeRoadAddress: String, | ||
@SerialName("latitude") | ||
val latitude: Double, | ||
@SerialName("longitude") | ||
val longitude: Double | ||
) |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/spoony/spoony/data/mapper/PlaceMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.spoony.spoony.data.mapper | ||
|
||
import com.spoony.spoony.data.dto.response.PlaceDto | ||
import com.spoony.spoony.domain.entity.PlaceEntity | ||
import com.spoony.spoony.presentation.register.model.Place | ||
|
||
fun PlaceDto.toPlaceEntity(): PlaceEntity = | ||
PlaceEntity( | ||
placeName = placeName, | ||
placeAddress = placeAddress, | ||
placeRoadAddress = placeRoadAddress, | ||
latitude = latitude, | ||
longitude = longitude | ||
) | ||
|
||
fun PlaceEntity.toPlace(): Place = | ||
Place( | ||
placeName = placeName, | ||
placeAddress = placeAddress, | ||
placeRoadAddress = placeRoadAddress, | ||
latitude = latitude, | ||
longitude = longitude | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/spoony/spoony/data/service/PlaceService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.spoony.spoony.data.service | ||
|
||
import com.spoony.spoony.data.dto.response.BaseResponse | ||
import com.spoony.spoony.data.dto.response.SearchPlaceData | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface PlaceService { | ||
@GET("api/v1/place/search") | ||
suspend fun searchPlace( | ||
@Query("query") query: String, | ||
@Query("display") display: Int = 5 | ||
): BaseResponse<SearchPlaceData> | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/spoony/spoony/domain/entity/PlaceEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.spoony.spoony.domain.entity | ||
|
||
data class PlaceEntity( | ||
val placeName: String, | ||
val placeAddress: String, | ||
val placeRoadAddress: String, | ||
val latitude: Double, | ||
val longitude: Double | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters