Skip to content

Commit

Permalink
[feat/UMC-5th-Coumo#79] : 동네소식 api 모델 및 요청, 응답코드 완성
Browse files Browse the repository at this point in the history
  • Loading branch information
psw9428 committed Feb 18, 2024
1 parent 7c94021 commit f352e85
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 24 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/com/umc/coumo/data/remote/api/CoumoApi.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.umc.coumo.data.remote.api

import com.umc.coumo.data.remote.model.request.RequestOwnerQRModel
import com.umc.coumo.data.remote.model.response.ResponseCommunityModel
import com.umc.coumo.data.remote.model.response.ResponseModel
import com.umc.coumo.data.remote.model.response.ResponseMyPageModel
import com.umc.coumo.data.remote.model.response.ResponseNearStoreModel
Expand Down Expand Up @@ -76,4 +77,10 @@ interface CoumoApi {
@Body body: RequestOwnerQRModel
): Response<Any>

@GET("/api/notice/around/list")
suspend fun getCommunityAll(
@Query("longitude") longitude: Double,
@Query("latitude") latitude: Double,
@Query("pageId") pageId: Int
): Response<ResponseModel<List<ResponseCommunityModel>>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import android.util.Log
import com.umc.coumo.App
import com.umc.coumo.data.remote.api.CoumoApi
import com.umc.coumo.data.remote.model.request.RequestOwnerQRModel
import com.umc.coumo.data.remote.model.response.ResponseCommunityModel
import com.umc.coumo.data.remote.model.response.ResponseMyPageModel
import com.umc.coumo.data.remote.model.response.ResponseNearStoreModel
import com.umc.coumo.data.remote.model.response.ResponsePopularStoreModel
import com.umc.coumo.data.remote.model.response.ResponseStoreDataModel
import com.umc.coumo.domain.model.CouponModel
import com.umc.coumo.domain.model.MenuModel
import com.umc.coumo.domain.model.MyPageModel
import com.umc.coumo.domain.model.PostModel
import com.umc.coumo.domain.model.RunTimeModel
import com.umc.coumo.domain.model.StoreCouponCountModel
import com.umc.coumo.domain.model.StoreInfoItemModel
Expand Down Expand Up @@ -99,6 +101,18 @@ class CoumoRepositoryImpl @Inject constructor(
return data.isSuccessful
}

override suspend fun getCommunityAll(
longitude: Double,
latitude: Double,
pageId: Int
): List<PostModel>? {
val data = coumoApi.getCommunityAll(
longitude = longitude,
latitude = latitude,
pageId = pageId)
return mapToPostModelList(data.body()?.result)
}

private fun mapToMyPageModel(response: ResponseMyPageModel?): MyPageModel? {
return if (response != null) {
MyPageModel(
Expand Down Expand Up @@ -176,6 +190,20 @@ class CoumoRepositoryImpl @Inject constructor(
}
}

private fun mapToPostModelList(responseList: List<ResponseCommunityModel>?): List<PostModel>? {
return responseList?.map { response ->
PostModel(
title = response.title,
contents = response.noticeContent,
date = response.createAt,
storeName = response.storeName,
imageUri = response.noticeImage.map {
Uri.parse(it)
}
)
}
}

private fun imageNullCheck(uri: String?): Uri? {
return if (uri != null) {
Uri.parse(uri)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.umc.coumo.data.remote.model.response

data class ResponseCommunityModel(
val title: String,
val noticeType: String,
val noticeContent: String,
val storeName: String,
val createAt: String,
val noticeImage: List<String?>
)
2 changes: 1 addition & 1 deletion app/src/main/java/com/umc/coumo/domain/model/PostModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ data class PostModel(
val contents: String,
val date: String,
val storeName: String,
val imageUri: List<Uri>?
val imageUri: List<Uri?>?
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.umc.coumo.domain.repository

import com.umc.coumo.domain.model.CouponModel
import com.umc.coumo.domain.model.MyPageModel
import com.umc.coumo.domain.model.PostModel
import com.umc.coumo.domain.model.StoreCouponCountModel
import com.umc.coumo.domain.model.StoreInfoItemModel
import com.umc.coumo.domain.model.StoreInfoModel
Expand Down Expand Up @@ -43,4 +44,6 @@ interface CoumoRepository {
customerId: Int,
stampCnt: Int,
): Boolean

suspend fun getCommunityAll(longitude: Double, latitude: Double, pageId: Int): List<PostModel>?
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ class CommunityAllFragment: BindingFragment<FragmentCommunityAllBinding>(R.layou
layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}

binding.rvAll2.apply {
adapter = storeInfoAdapter
addItemDecoration(ItemSpacingDecoration(requireContext(),resources.getDimensionPixelSize(R.dimen.item_between_horizontal)))
layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}

val list = listOf<StoreInfoItemModel>(
StoreInfoItemModel(1, null,"앙떼띠 로스터리(강남점)", "강남구 테헤란로 43-7", "양떼띠 로스터리는 2017년에 오픈한 강남의 유명 카페입니다. 강남역 직장인들을 위해 평일 오전 7시~9시에\n" +
"아메리카노 2000원 이벤트를 진행 중입니다."),
Expand Down
18 changes: 1 addition & 17 deletions app/src/main/res/layout/fragment_community_all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/all_title_1"
android:text="우리동네 소식들 모아보기"
android:layout_marginTop="36dp"
style="@style/CommunityTitle"
android:layout_marginStart="@dimen/horizontal_padding"
Expand All @@ -28,22 +28,6 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/all_title_2"
style="@style/CommunityTitle"
android:layout_marginTop="36dp"
android:layout_marginStart="@dimen/horizontal_padding"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_all_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="32dp"/>
</androidx.appcompat.widget.LinearLayoutCompat>

</layout>

0 comments on commit f352e85

Please sign in to comment.