-
Notifications
You must be signed in to change notification settings - Fork 1
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
…ap-api [Feature/#30] : 지도 api 연결
- Loading branch information
Showing
13 changed files
with
276 additions
and
63 deletions.
There are no files selected for viewing
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
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
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/hackathon/alddeul_babsang/data/datasource/MapDataSource.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,10 @@ | ||
package com.hackathon.alddeul_babsang.data.datasource | ||
|
||
import com.hackathon.alddeul_babsang.data.dto.BaseResponse | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseMapStoreDetailDto | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseMapStoresDto | ||
|
||
interface MapDataSource { | ||
suspend fun getMapStores(): BaseResponse<List<ResponseMapStoresDto>> | ||
suspend fun getMapStoreDetail(id: Long): BaseResponse<ResponseMapStoreDetailDto> | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/hackathon/alddeul_babsang/data/datasourceimpl/MapDataSourceImpl.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.hackathon.alddeul_babsang.data.datasourceimpl | ||
|
||
import com.hackathon.alddeul_babsang.data.datasource.MapDataSource | ||
import com.hackathon.alddeul_babsang.data.dto.BaseResponse | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseMapStoreDetailDto | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseMapStoresDto | ||
import com.hackathon.alddeul_babsang.data.service.MapApiService | ||
import javax.inject.Inject | ||
|
||
class MapDataSourceImpl @Inject constructor( | ||
private val mapApiService: MapApiService | ||
) : MapDataSource { | ||
override suspend fun getMapStores(): BaseResponse<List<ResponseMapStoresDto>> { | ||
return mapApiService.getMapStores() | ||
} | ||
|
||
override suspend fun getMapStoreDetail(id: Long): BaseResponse<ResponseMapStoreDetailDto> { | ||
return mapApiService.getMapStoreDetail(id) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...rc/main/java/com/hackathon/alddeul_babsang/data/dto/response/ResponseMapStoreDetailDto.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,15 @@ | ||
package com.hackathon.alddeul_babsang.data.dto.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseMapStoreDetailDto ( | ||
@SerialName("id") val id: Long, | ||
@SerialName("name") val name: String, | ||
@SerialName("category") val category: String, | ||
@SerialName("address") val address: String, | ||
@SerialName("contact") val contact: String, | ||
@SerialName("imageUrl") val imageUrl: String? = null, | ||
@SerialName("favorite") val favorite: Boolean, | ||
) |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/hackathon/alddeul_babsang/data/dto/response/ResponseMapStoresDto.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,15 @@ | ||
package com.hackathon.alddeul_babsang.data.dto.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseMapStoresDto ( | ||
@SerialName("storeId") val storeId: Long, | ||
@SerialName("name") val name: String, | ||
@SerialName("category") val category: String, | ||
@SerialName("address") val address: String, | ||
@SerialName("region") val region: String, | ||
@SerialName("latitude") val latitude: Double, | ||
@SerialName("longitude") val longitude: Double, | ||
) |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/hackathon/alddeul_babsang/data/repositoryimpl/MapRepositoryImpl.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.hackathon.alddeul_babsang.data.repositoryimpl | ||
|
||
import com.hackathon.alddeul_babsang.data.datasource.MapDataSource | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseMapStoreDetailDto | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseMapStoresDto | ||
import com.hackathon.alddeul_babsang.domain.repository.MapRepository | ||
import javax.inject.Inject | ||
|
||
class MapRepositoryImpl @Inject constructor( | ||
private val mapDataSource: MapDataSource | ||
) : MapRepository { | ||
override suspend fun getMapStores(): Result<List<ResponseMapStoresDto>> { | ||
return runCatching { | ||
mapDataSource.getMapStores().result ?: emptyList() | ||
} | ||
} | ||
|
||
override suspend fun getMapStoreDetail(id: Long): Result<ResponseMapStoreDetailDto?> { | ||
return runCatching { | ||
mapDataSource.getMapStoreDetail(id).result | ||
} | ||
} | ||
} |
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/hackathon/alddeul_babsang/data/service/MapApiService.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.hackathon.alddeul_babsang.data.service | ||
|
||
import com.hackathon.alddeul_babsang.data.dto.BaseResponse | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseMapStoreDetailDto | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseMapStoresDto | ||
import com.sopt.data.service.ApiKeyStorage.ID | ||
import com.sopt.data.service.ApiKeyStorage.MAP | ||
import com.sopt.data.service.ApiKeyStorage.STORES | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
interface MapApiService { | ||
@GET("/$MAP/$STORES") | ||
suspend fun getMapStores(): BaseResponse<List<ResponseMapStoresDto>> | ||
|
||
@GET("/$MAP/$STORES/{$ID}") | ||
suspend fun getMapStoreDetail( | ||
@Path("id") id: Long | ||
): BaseResponse<ResponseMapStoreDetailDto> | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/hackathon/alddeul_babsang/domain/repository/MapRepository.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.hackathon.alddeul_babsang.domain.repository | ||
|
||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseMapStoreDetailDto | ||
import com.hackathon.alddeul_babsang.data.dto.response.ResponseMapStoresDto | ||
|
||
interface MapRepository { | ||
suspend fun getMapStores(): Result<List<ResponseMapStoresDto>> | ||
suspend fun getMapStoreDetail(id: Long): Result<ResponseMapStoreDetailDto?> | ||
} |
Oops, something went wrong.