From f352e8564db69b05033b442f29b71188281a5a58 Mon Sep 17 00:00:00 2001 From: psw9428 Date: Sun, 18 Feb 2024 19:11:36 +0900 Subject: [PATCH] =?UTF-8?q?[feat/#79]=20:=20=EB=8F=99=EB=84=A4=EC=86=8C?= =?UTF-8?q?=EC=8B=9D=20api=20=EB=AA=A8=EB=8D=B8=20=EB=B0=8F=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD,=20=EC=9D=91=EB=8B=B5=EC=BD=94=EB=93=9C=20=EC=99=84?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/umc/coumo/data/remote/api/CoumoApi.kt | 7 +++++ .../remote/datasource/CoumoRepositoryImpl.kt | 28 +++++++++++++++++++ .../model/response/ResponseCommunityModel.kt | 10 +++++++ .../com/umc/coumo/domain/model/PostModel.kt | 2 +- .../domain/repository/CoumoRepository.kt | 3 ++ .../community/CommunityAllFragment.kt | 6 ---- .../res/layout/fragment_community_all.xml | 18 +----------- 7 files changed, 50 insertions(+), 24 deletions(-) create mode 100644 app/src/main/java/com/umc/coumo/data/remote/model/response/ResponseCommunityModel.kt diff --git a/app/src/main/java/com/umc/coumo/data/remote/api/CoumoApi.kt b/app/src/main/java/com/umc/coumo/data/remote/api/CoumoApi.kt index baba625..d2da423 100644 --- a/app/src/main/java/com/umc/coumo/data/remote/api/CoumoApi.kt +++ b/app/src/main/java/com/umc/coumo/data/remote/api/CoumoApi.kt @@ -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 @@ -76,4 +77,10 @@ interface CoumoApi { @Body body: RequestOwnerQRModel ): Response + @GET("/api/notice/around/list") + suspend fun getCommunityAll( + @Query("longitude") longitude: Double, + @Query("latitude") latitude: Double, + @Query("pageId") pageId: Int + ): Response>> } \ No newline at end of file diff --git a/app/src/main/java/com/umc/coumo/data/remote/datasource/CoumoRepositoryImpl.kt b/app/src/main/java/com/umc/coumo/data/remote/datasource/CoumoRepositoryImpl.kt index 1e6d820..dcafe28 100644 --- a/app/src/main/java/com/umc/coumo/data/remote/datasource/CoumoRepositoryImpl.kt +++ b/app/src/main/java/com/umc/coumo/data/remote/datasource/CoumoRepositoryImpl.kt @@ -5,6 +5,7 @@ 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 @@ -12,6 +13,7 @@ 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 @@ -99,6 +101,18 @@ class CoumoRepositoryImpl @Inject constructor( return data.isSuccessful } + override suspend fun getCommunityAll( + longitude: Double, + latitude: Double, + pageId: Int + ): List? { + 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( @@ -176,6 +190,20 @@ class CoumoRepositoryImpl @Inject constructor( } } + private fun mapToPostModelList(responseList: List?): List? { + 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) diff --git a/app/src/main/java/com/umc/coumo/data/remote/model/response/ResponseCommunityModel.kt b/app/src/main/java/com/umc/coumo/data/remote/model/response/ResponseCommunityModel.kt new file mode 100644 index 0000000..f2d72e8 --- /dev/null +++ b/app/src/main/java/com/umc/coumo/data/remote/model/response/ResponseCommunityModel.kt @@ -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 +) diff --git a/app/src/main/java/com/umc/coumo/domain/model/PostModel.kt b/app/src/main/java/com/umc/coumo/domain/model/PostModel.kt index 9eb8a5f..577c116 100644 --- a/app/src/main/java/com/umc/coumo/domain/model/PostModel.kt +++ b/app/src/main/java/com/umc/coumo/domain/model/PostModel.kt @@ -7,5 +7,5 @@ data class PostModel( val contents: String, val date: String, val storeName: String, - val imageUri: List? + val imageUri: List? ) diff --git a/app/src/main/java/com/umc/coumo/domain/repository/CoumoRepository.kt b/app/src/main/java/com/umc/coumo/domain/repository/CoumoRepository.kt index f6f6304..7e602bd 100644 --- a/app/src/main/java/com/umc/coumo/domain/repository/CoumoRepository.kt +++ b/app/src/main/java/com/umc/coumo/domain/repository/CoumoRepository.kt @@ -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 @@ -43,4 +44,6 @@ interface CoumoRepository { customerId: Int, stampCnt: Int, ): Boolean + + suspend fun getCommunityAll(longitude: Double, latitude: Double, pageId: Int): List? } \ No newline at end of file diff --git a/app/src/main/java/com/umc/coumo/presentation/fragment/community/CommunityAllFragment.kt b/app/src/main/java/com/umc/coumo/presentation/fragment/community/CommunityAllFragment.kt index 39406b5..7880c04 100644 --- a/app/src/main/java/com/umc/coumo/presentation/fragment/community/CommunityAllFragment.kt +++ b/app/src/main/java/com/umc/coumo/presentation/fragment/community/CommunityAllFragment.kt @@ -29,12 +29,6 @@ class CommunityAllFragment: BindingFragment(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(1, null,"앙떼띠 로스터리(강남점)", "강남구 테헤란로 43-7", "양떼띠 로스터리는 2017년에 오픈한 강남의 유명 카페입니다. 강남역 직장인들을 위해 평일 오전 7시~9시에\n" + "아메리카노 2000원 이벤트를 진행 중입니다."), diff --git a/app/src/main/res/layout/fragment_community_all.xml b/app/src/main/res/layout/fragment_community_all.xml index 5dcbee9..fe795ab 100644 --- a/app/src/main/res/layout/fragment_community_all.xml +++ b/app/src/main/res/layout/fragment_community_all.xml @@ -15,7 +15,7 @@ - - - \ No newline at end of file