-
Notifications
You must be signed in to change notification settings - Fork 0
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/#117] 장소 검색 API 세팅 #121
Changes from 1 commit
f3ec0f1
1340a59
5711f6a
be2bc37
e1d9e0d
4348c27
b4b54da
210668e
ead1ef5
63b98f1
13b8f42
4921eae
4229433
60e87fb
fae9c68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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> | ||
} |
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) | ||
} |
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 | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: 컨벤션에 맞게 네이밍 수정해봅시다~~ 노션 읽어라~~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 히히 수정했습니다요 |
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 | ||
) |
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 = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: 저희 컨벤션에 맞게 함수명 고쳐주세요~~!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 수정했습니당~ |
||
PlaceEntity( | ||
placeName = placeName, | ||
placeAddress = placeAddress, | ||
placeRoadAddress = placeRoadAddress, | ||
latitude = latitude, | ||
longitude = longitude | ||
) | ||
|
||
fun PlaceEntity.toPlace(): Place = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p2) 함수명이 저희 컨벤션과 다른 것 같습니다! 수정 해주세요~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코딩 컨벤션과 맞게 수정했습니다~ |
||
Place( | ||
placeName = placeName, | ||
placeAddress = placeAddress, | ||
placeRoadAddress = placeRoadAddress, | ||
latitude = latitude, | ||
longitude = longitude | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
package com.spoony.spoony.data.repositoryimpl | ||
|
||
import android.net.Uri | ||
import com.spoony.spoony.data.datasource.PlaceDataSource | ||
import com.spoony.spoony.data.mapper.toPlace | ||
import com.spoony.spoony.data.mapper.toPlaceEntity | ||
import com.spoony.spoony.domain.repository.RegisterRepository | ||
import com.spoony.spoony.presentation.register.model.Category | ||
import com.spoony.spoony.presentation.register.model.Place | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: 어라라????? data레이어에서 presentation 레이어의 모델을 사용하네요?? 수정해주세요!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 싹 수정했습니다! |
||
import javax.inject.Inject | ||
|
||
class RegisterRepositoryImpl @Inject constructor() : RegisterRepository { | ||
class RegisterRepositoryImpl @Inject constructor( | ||
private val placeDataSource: PlaceDataSource | ||
) : RegisterRepository { | ||
override suspend fun getCategories(): Result<List<Category>> = Result.success( | ||
listOf( | ||
Category( | ||
|
@@ -54,45 +59,15 @@ class RegisterRepositoryImpl @Inject constructor() : RegisterRepository { | |
) | ||
) | ||
|
||
override suspend fun searchPlace(query: String, display: Int): Result<List<Place>> = Result.success( | ||
listOf( | ||
Place( | ||
placeName = "스타벅스 강남대로점", | ||
placeAddress = "서울특별시 서초구 서초동 1305-7", | ||
placeRoadAddress = "서울특별시 서초구 강남대로 369 (서초동)", | ||
latitude = 37.4979, | ||
longitude = 127.0276 | ||
), | ||
Place( | ||
placeName = "스타벅스 신촌역점", | ||
placeAddress = "서울특별시 서대문구 창천동 30-1", | ||
placeRoadAddress = "서울특별시 서대문구 연세로 10-1 (창천동)", | ||
latitude = 37.5598, | ||
longitude = 126.9423 | ||
), | ||
Place( | ||
placeName = "스타벅스 홍대역점", | ||
placeAddress = "서울특별시 마포구 서교동 358-11", | ||
placeRoadAddress = "서울특별시 마포구 양화로 166 (서교동)", | ||
latitude = 37.5569, | ||
longitude = 126.9237 | ||
), | ||
Place( | ||
placeName = "스타벅스 부산센텀시티점", | ||
placeAddress = "부산광역시 해운대구 우동 1505", | ||
placeRoadAddress = "부산광역시 해운대구 센텀남대로 35 (우동)", | ||
latitude = 35.1698, | ||
longitude = 129.1315 | ||
), | ||
Place( | ||
placeName = "스타벅스 대구동성로점", | ||
placeAddress = "대구광역시 중구 동성로3가 11", | ||
placeRoadAddress = "대구광역시 중구 동성로 55 (동성로3가)", | ||
latitude = 35.8703, | ||
longitude = 128.5978 | ||
) | ||
) | ||
) | ||
override suspend fun searchPlace(query: String, display: Int): Result<List<Place>> = runCatching { | ||
val response = placeDataSource.searchPlace(query, display) | ||
if (!response.success || response.data == null) { | ||
throw IllegalStateException(response.error?.message ?: "에러 발생") | ||
} | ||
response.data.placeList.map { placeDto -> | ||
placeDto.toPlaceEntity().toPlace() | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p1) 저희 컨벤션 맞게 runCatching 내부에서 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. override suspend fun searchPlace(query: String, display: Int): Result<List<Place>> = runCatching {
placeDataSource.getPlaces(query, display).data!!.placeList
.map { it.toDomain().toPresentation() }
} 로 수정했습니다! |
||
|
||
override suspend fun checkDuplicatePlace( | ||
userId: Long, | ||
|
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> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.spoony.spoony.domain.entity | ||
|
||
data class PlaceEntity( | ||
val placeName: String, | ||
val placeAddress: String, | ||
val placeRoadAddress: String, | ||
val latitude: Double, | ||
val longitude: Double | ||
) | ||
|
||
data class PlaceSearchResultEntity( | ||
val placeList: List<PlaceEntity> | ||
) |
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.
p4) 추후 세홍이형 PR 머지하게되면 충돌 날 것 같아요!
꼭 해결하고 머지부탁드려요 :)
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.
네ㅎ 컨플릭 해결하겠습니다!