-
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 #95 from TeamPINGLE/feat-pin-list-api-connection
[feat] 핀 목록 (좌표 필터링x) API 연동
- Loading branch information
Showing
16 changed files
with
243 additions
and
129 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/MapRemoteDataSource.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.ResponsePinListDto | ||
import org.sopt.pingle.util.base.BaseResponse | ||
|
||
interface MapRemoteDataSource { | ||
suspend fun getPinListWithoutFiltering(teamId: Long, category: String?): BaseResponse<List<ResponsePinListDto>> | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/org/sopt/pingle/data/datasourceimpl/remote/MapRemoteDataSourceImpl.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 org.sopt.pingle.data.datasourceimpl.remote | ||
|
||
import javax.inject.Inject | ||
import org.sopt.pingle.data.datasource.remote.MapRemoteDataSource | ||
import org.sopt.pingle.data.model.remote.response.ResponsePinListDto | ||
import org.sopt.pingle.data.service.MapService | ||
import org.sopt.pingle.util.base.BaseResponse | ||
|
||
class MapRemoteDataSourceImpl @Inject constructor( | ||
private val mapService: MapService | ||
) : MapRemoteDataSource { | ||
override suspend fun getPinListWithoutFiltering( | ||
teamId: Long, | ||
category: String? | ||
): BaseResponse<List<ResponsePinListDto>> = | ||
mapService.getPinListWithoutFiltering(teamId = teamId, category = category) | ||
} |
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/org/sopt/pingle/data/model/remote/request/RequestPinListDto.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 RequestPinListDto( | ||
@SerialName("category") | ||
val category: String? | ||
) |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponsePinListDto.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,27 @@ | ||
package org.sopt.pingle.data.model.remote.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.sopt.pingle.domain.model.PinEntity | ||
|
||
@Serializable | ||
data class ResponsePinListDto( | ||
@SerialName("id") | ||
val id: Long, | ||
@SerialName("x") | ||
val x: Double, | ||
@SerialName("y") | ||
val y: Double, | ||
@SerialName("category") | ||
val category: String, | ||
@SerialName("meetingCount") | ||
val meetingCount: Int | ||
) { | ||
fun toPinEntity() = PinEntity( | ||
id = this.id, | ||
x = this.x, | ||
y = this.y, | ||
category = this.category, | ||
meetingCount = this.meetingCount | ||
) | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/org/sopt/pingle/data/repository/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,27 @@ | ||
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.MapRemoteDataSource | ||
import org.sopt.pingle.domain.model.PinEntity | ||
import org.sopt.pingle.domain.repository.MapRepository | ||
|
||
class MapRepositoryImpl @Inject constructor( | ||
private val mapDataSource: MapRemoteDataSource | ||
) : MapRepository { | ||
override suspend fun getPinListWithoutFiltering( | ||
teamId: Long, | ||
category: String? | ||
): Flow<List<PinEntity>> = flow { | ||
val result = runCatching { | ||
mapDataSource.getPinListWithoutFiltering( | ||
teamId = teamId, | ||
category = category | ||
).data.map { pin -> | ||
pin.toPinEntity() | ||
} | ||
} | ||
emit(result.getOrThrow()) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/org/sopt/pingle/data/service/MapService.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 org.sopt.pingle.data.service | ||
|
||
import org.sopt.pingle.data.model.remote.response.ResponsePinListDto | ||
import org.sopt.pingle.util.base.BaseResponse | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
|
||
interface MapService { | ||
@GET("$VERSION/$TEAMS/{$TEAM_ID}/$PINS") | ||
suspend fun getPinListWithoutFiltering( | ||
@Path("$TEAM_ID") teamId: Long, | ||
@Query(CATEGORY) category: String? | ||
): BaseResponse<List<ResponsePinListDto>> | ||
|
||
companion object { | ||
const val VERSION = "v1" | ||
const val TEAMS = "teams" | ||
const val PINS = "pins" | ||
const val TEAM_ID = "teamId" | ||
const val CATEGORY = "category" | ||
} | ||
} |
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/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,8 @@ | ||
package org.sopt.pingle.domain.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.sopt.pingle.domain.model.PinEntity | ||
|
||
interface MapRepository { | ||
suspend fun getPinListWithoutFiltering(teamId: Long, category: String?): Flow<List<PinEntity>> | ||
} |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/org/sopt/pingle/domain/usecase/GetPinListWithoutFilteringUseCase.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.PinEntity | ||
import org.sopt.pingle.domain.repository.MapRepository | ||
|
||
class GetPinListWithoutFilteringUseCase( | ||
private val mapRepository: MapRepository | ||
) { | ||
suspend operator fun invoke(teamId: Long, category: String?): Flow<List<PinEntity>> = | ||
mapRepository.getPinListWithoutFiltering(teamId = teamId, category = category) | ||
} |
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.