-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from TeamPINGLE/feat-plan-location-api
[feat] 장소 검색 API 연동
- Loading branch information
Showing
22 changed files
with
244 additions
and
77 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/pingle/data/datasource/remote/PlanRemoteDataSource.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 org.sopt.pingle.data.datasource.remote | ||
|
||
import org.sopt.pingle.data.model.remote.response.ResponsePlanDto | ||
import org.sopt.pingle.util.base.BaseResponse | ||
|
||
interface PlanRemoteDataSource { | ||
suspend fun getPlanLocation(searchWord: String): BaseResponse<List<ResponsePlanDto>> | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/sopt/pingle/data/datasourceimpl/remote/PlanRemoteDataSourceImpl.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 org.sopt.pingle.data.datasourceimpl.remote | ||
|
||
import javax.inject.Inject | ||
import org.sopt.pingle.data.datasource.remote.PlanRemoteDataSource | ||
import org.sopt.pingle.data.model.remote.response.ResponsePlanDto | ||
import org.sopt.pingle.data.service.PlanService | ||
import org.sopt.pingle.util.base.BaseResponse | ||
|
||
class PlanRemoteDataSourceImpl @Inject constructor( | ||
private val planService: PlanService | ||
) : PlanRemoteDataSource { | ||
override suspend fun getPlanLocation(searchWord: String): BaseResponse<List<ResponsePlanDto>> = | ||
planService.getPlanLocationList(searchWord = searchWord) | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/sopt/pingle/data/model/remote/request/RequestPlanDto.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 org.sopt.pingle.data.model.remote.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestPlanDto( | ||
@SerialName("search") | ||
val search: String | ||
) |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponsePlanDto.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,26 @@ | ||
package org.sopt.pingle.data.model.remote.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.sopt.pingle.domain.model.PlanLocationEntity | ||
|
||
@Serializable | ||
data class ResponsePlanDto( | ||
@SerialName("x") | ||
val xCoordinate: Double, | ||
@SerialName("y") | ||
val yCoordinate: Double, | ||
@SerialName("location") | ||
val locationName: String, | ||
@SerialName("address") | ||
val locationAddress: String, | ||
@SerialName("roadAddress") | ||
val locationRoadAddress: String | ||
) { | ||
fun toPlanLocationEntity() = PlanLocationEntity( | ||
location = locationName, | ||
address = locationAddress, | ||
x = xCoordinate, | ||
y = yCoordinate | ||
) | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/org/sopt/pingle/data/repository/PlanRepositoryImpl.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,22 @@ | ||
package org.sopt.pingle.data.repository | ||
|
||
import javax.inject.Inject | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import org.sopt.pingle.data.datasource.remote.PlanRemoteDataSource | ||
import org.sopt.pingle.domain.model.PlanLocationEntity | ||
import org.sopt.pingle.domain.repository.PlanRepository | ||
|
||
class PlanRepositoryImpl @Inject constructor( | ||
private val planRemoteDataSource: PlanRemoteDataSource | ||
) : PlanRepository { | ||
override suspend fun getPlanLocationList(searchWord: String): Flow<List<PlanLocationEntity>> = | ||
flow { | ||
val result = runCatching { | ||
planRemoteDataSource.getPlanLocation(searchWord = searchWord).data.map { planLocation -> | ||
planLocation.toPlanLocationEntity() | ||
} | ||
} | ||
emit(result.getOrThrow()) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/org/sopt/pingle/data/service/PlanService.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,19 @@ | ||
package org.sopt.pingle.data.service | ||
|
||
import org.sopt.pingle.data.model.remote.response.ResponsePlanDto | ||
import org.sopt.pingle.util.base.BaseResponse | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface PlanService { | ||
@GET("$VERSION/$LOCATION") | ||
suspend fun getPlanLocationList( | ||
@Query(SEARCH_WORD) searchWord: String | ||
): BaseResponse<List<ResponsePlanDto>> | ||
|
||
companion object { | ||
const val VERSION = "v1" | ||
const val LOCATION = "location" | ||
const val SEARCH_WORD = "search" | ||
} | ||
} |
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
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
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/pingle/domain/repository/PlanRepository.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 org.sopt.pingle.domain.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.sopt.pingle.domain.model.PlanLocationEntity | ||
|
||
interface PlanRepository { | ||
suspend fun getPlanLocationList(searchWord: String): Flow<List<PlanLocationEntity>> | ||
} |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/org/sopt/pingle/domain/usecase/GetPlanLocationListUseCase.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,12 @@ | ||
package org.sopt.pingle.domain.usecase | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.sopt.pingle.domain.model.PlanLocationEntity | ||
import org.sopt.pingle.domain.repository.PlanRepository | ||
|
||
class GetPlanLocationListUseCase( | ||
private val planRepository: PlanRepository | ||
) { | ||
suspend operator fun invoke(searchWord: String): Flow<List<PlanLocationEntity>> = | ||
planRepository.getPlanLocationList(searchWord = searchWord) | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/sopt/pingle/presentation/model/PlanLocationModel.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 org.sopt.pingle.presentation.model | ||
|
||
import androidx.databinding.ObservableBoolean | ||
import org.sopt.pingle.domain.model.PlanLocationEntity | ||
|
||
data class PlanLocationModel( | ||
val planLocation: PlanLocationEntity, | ||
var isSelected: ObservableBoolean = ObservableBoolean(false) | ||
) |
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
Oops, something went wrong.