-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] 장소 검색 API 연동 #106
Merged
Merged
[feat] 장소 검색 API 연동 #106
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a985683
[add] #92 RequestPlanLocationDto, ResponsePlanLocationDto 추가
HAJIEUN02 af8ebb9
Merge branch 'develop' into feat-plan-location-api
HAJIEUN02 6ce978b
[chore] #92 BaseRespone 반영해 Dto 수정
HAJIEUN02 ff3cc01
[feat] #92 HiltViewModel, AndroidEntryPoint 어노테이션 추가
HAJIEUN02 8d7446a
[feat] #92 클린아키텍처 및 DI 적용한 Repository, UseCase, DataSource,Service 추가
HAJIEUN02 5ea16de
[feat] #92 단일선택 로직을 제외한 서버통신 구현
HAJIEUN02 6b7e477
Merge branch 'develop' into feat-plan-location-api
HAJIEUN02 296ee41
[feat] #102 번개 생성 API 연동
HAJIEUN02 3c3131a
[mod] #102 엠티뷰, 버튼 비활성화 로직 수정
HAJIEUN02 20a127a
[chore] #102 ktlint 적용
HAJIEUN02 009ba19
[feat] #92 번개 생성 API 연동
HAJIEUN02 e03ec5f
[mod] #92 엠티뷰, 버튼 비활성화 로직 수정
HAJIEUN02 ed0741e
[chore] #92 ktlint 적용
HAJIEUN02 1138b7e
Merge branch 'develop' into feat-plan-location-api
HAJIEUN02 6198abd
Merge remote-tracking branch 'origin/feat-plan-location-api' into fea…
HAJIEUN02 016b037
[chore] #102 ktlint 적용
HAJIEUN02 cd848b2
[chore] #92 코드리뷰 반영
HAJIEUN02 15ed996
[chore] #92 ktlint 적용
HAJIEUN02 7e5ffc4
Merge branch 'develop' into feat-plan-location-api
HAJIEUN02 a047539
[chore] #92 코드리뷰 반영 및 ktlint 적용
HAJIEUN02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
개인적인 생각으로 조건문이 Boolean이라면 when문 보다는 if else로 하는 것이 더 깔끔할 것 같다는 생각이 들어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 코틀린에만 when이 있어서 이걸 쓰구 싶음여 ㅋ