Skip to content

Commit

Permalink
[FEAT] 주변 게시글을 받아오는 API 요청을 위한 밑작업
Browse files Browse the repository at this point in the history
  • Loading branch information
LJG7123 committed Nov 30, 2023
1 parent f3ea121 commit 532cdae
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package com.boostcampwm2023.snappoint.data.mapper
import com.boostcampwm2023.snappoint.data.remote.model.BlockType
import com.boostcampwm2023.snappoint.data.remote.model.File
import com.boostcampwm2023.snappoint.data.remote.model.PostBlock
import com.boostcampwm2023.snappoint.data.remote.model.response.GetAroundPostResponse
import com.boostcampwm2023.snappoint.presentation.model.PositionState
import com.boostcampwm2023.snappoint.presentation.model.PostBlockState
import com.boostcampwm2023.snappoint.presentation.model.PostSummaryState

fun PostBlock.asPostBlockState(): PostBlockState {
return when(type){
Expand Down Expand Up @@ -71,3 +73,12 @@ fun PostBlock.asPositionState(): PositionState {
longitude = this.longitude!!
)
}

fun GetAroundPostResponse.asPostSummaryState(): PostSummaryState {
return PostSummaryState(
title = this.title,
author = "",
timeStamp = this.createdAt,
postBlocks = this.blocks.map { it.asPostBlockState() }
)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.boostcampwm2023.snappoint.data.remote

import com.boostcampwm2023.snappoint.data.remote.model.request.CreatePostRequest
import com.boostcampwm2023.snappoint.data.remote.model.request.GetAroundPostRequest
import com.boostcampwm2023.snappoint.data.remote.model.request.SignInRequest
import com.boostcampwm2023.snappoint.data.remote.model.request.SignupRequest
import com.boostcampwm2023.snappoint.data.remote.model.response.CreatePostResponse
import com.boostcampwm2023.snappoint.data.remote.model.response.GetAroundPostResponse
import com.boostcampwm2023.snappoint.data.remote.model.response.ImageResponse
import com.boostcampwm2023.snappoint.data.remote.model.response.ImageUriResponse
import com.boostcampwm2023.snappoint.data.remote.model.response.PostImageResponse
Expand Down Expand Up @@ -52,4 +54,9 @@ interface SnapPointApi {
suspend fun postImage(
@Part bitmap: MultipartBody.Part
): PostImageResponse

@GET("posts")
suspend fun getAroundPost(
@Body getAroundPostRequest: GetAroundPostRequest
): List<GetAroundPostResponse>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.boostcampwm2023.snappoint.data.repository

import com.boostcampwm2023.snappoint.data.remote.model.response.CreatePostResponse
import com.boostcampwm2023.snappoint.data.remote.model.response.GetAroundPostResponse
import com.boostcampwm2023.snappoint.presentation.model.PostBlockState
import kotlinx.coroutines.flow.Flow

Expand All @@ -10,4 +11,5 @@ interface PostRepository {
fun getVideo(uri: String): Flow<ByteArray>
fun getVideoUri(video: ByteArray): Flow<Unit>
fun postCreatePost(title: String, postBlocks: List<PostBlockState>): Flow<CreatePostResponse>
fun getAroundPost(leftBottom: String, rightTop: String): Flow<List<GetAroundPostResponse>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.boostcampwm2023.snappoint.data.remote.SnapPointApi
import com.boostcampwm2023.snappoint.data.remote.model.File
import com.boostcampwm2023.snappoint.data.remote.model.request.CreatePostRequest
import com.boostcampwm2023.snappoint.data.remote.model.response.CreatePostResponse
import com.boostcampwm2023.snappoint.data.remote.model.response.GetAroundPostResponse
import com.boostcampwm2023.snappoint.presentation.model.PostBlockState
import com.boostcampwm2023.snappoint.presentation.util.toByteArray
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -87,4 +88,8 @@ class PostRepositoryImpl @Inject constructor(
snapPointApi.createPost(request)
}
}

override fun getAroundPost(leftBottom: String, rightTop: String): Flow<List<GetAroundPostResponse>> {
TODO("Not yet implemented")
}
}

0 comments on commit 532cdae

Please sign in to comment.