Skip to content

Commit

Permalink
Merge pull request #263 from TeamBeMyPlan/feat/262
Browse files Browse the repository at this point in the history
[FEAT] #262 머지를 위한 임시브랜치
  • Loading branch information
briandr97 authored May 16, 2022
2 parents 9b99dfd + a8d6d6b commit e99b3b4
Show file tree
Hide file tree
Showing 24 changed files with 281 additions and 87 deletions.
17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/src/main/java/co/kr/bemyplan/data/api/ApiService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ object ApiService {
.build()

// 인기 여행일정 조회
val homePopularService: HomePopularService = retrofit.create(HomePopularService::class.java)
//val homePopularService: HomePopularService = retrofit.create(HomePopularService::class.java)

// 구매 후 포스트 조회
val afterPostService: AfterPostService = retrofit.create(AfterPostService::class.java)

// 최신 여행 일정 조회
val homeNewService: HomeNewService = retrofit.create(HomeNewService::class.java)
//val homeNewService: HomeNewService = retrofit.create(HomeNewService::class.java)

// 에디터 추천 여행 일정 조회
val homeSuggestService: HomeSuggestService = retrofit.create(HomeSuggestService::class.java)
//val homeSuggestService: HomeSuggestService = retrofit.create(HomeSuggestService::class.java)

// 회원 탈퇴
val withdrawService: WithdrawService = retrofit.create(WithdrawService::class.java)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/co/kr/bemyplan/data/api/HomeNewService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import retrofit2.Call
import retrofit2.http.GET

interface HomeNewService {
@GET("/api/v1/post/new")
fun getNewData(): Call<ResponseHomeData>
@GET("/v1/plans?size=10&sort=createdAt,desc")
suspend fun getNewData() : ResponseHomeData
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package co.kr.bemyplan.data.api

import co.kr.bemyplan.data.entity.main.home.ResponseHomePopularData
import co.kr.bemyplan.data.entity.main.home.ResponseHomeData
import retrofit2.Call
import retrofit2.http.GET

interface HomePopularService {
@GET("/api/v1/post/popular")
fun getPopularData(): Call<ResponseHomePopularData>
@GET("/v1/plans?size=10&sort=orderCnt,desc")
suspend fun getPopularData(): ResponseHomeData
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import retrofit2.Call
import retrofit2.http.GET

interface HomeSuggestService {
@GET("/api/v1/post/suggest")
fun getSuggestData(): Call<ResponseHomeData>
@GET("/v1/plans/bemyplanPick?size=5&sort=id,desc")
suspend fun getSuggestData(): ResponseHomeData
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
package co.kr.bemyplan.data.entity.main.home

import com.google.gson.annotations.SerializedName
import co.kr.bemyplan.domain.model.main.home.HomeDomainData

data class ResponseHomeData(
val data: ResponseHomeItems,
val totalPage : Int
val message : String,
val resultCode : String
){
data class ResponseHomeItems(
val items: List<HomeData>
){
data class HomeData(
@SerializedName("post_id")
val postId: Int,
val title: String,
val author : String,
@SerializedName("thumbnail_url")
val thumbnailUrl: String,
val price: Int,
@SerializedName("is_purchased")
val isPurchased : Boolean,
@SerializedName("is_scraped")
val isScraped : Boolean
)
}
val contents : List<HomeDomainData>,
val nextCursor : Int
)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package co.kr.bemyplan.data.repository.main.home

import co.kr.bemyplan.data.api.HomeNewService
import co.kr.bemyplan.domain.model.main.home.HomeDomainData
import co.kr.bemyplan.domain.repository.HomeNewRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import javax.inject.Inject

class HomeNewRepositoryImpl @Inject constructor(
private val homeNewService : HomeNewService,
private val coroutineDispatcher: CoroutineDispatcher
) : HomeNewRepository {
override suspend fun getHomeNewData(): List<HomeDomainData> {
return withContext(coroutineDispatcher){
homeNewService.getNewData().data.contents
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package co.kr.bemyplan.data.repository.main.home

import co.kr.bemyplan.data.api.HomePopularService
import co.kr.bemyplan.domain.model.main.home.HomeDomainData
import co.kr.bemyplan.domain.repository.HomePopularRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import javax.inject.Inject

class HomePopularRepositoryImpl @Inject constructor(
private val homePopularService: HomePopularService,
private val coroutineDispatcher: CoroutineDispatcher
) : HomePopularRepository {
override suspend fun getHomePopularData(): List<HomeDomainData> {
return withContext(coroutineDispatcher){
homePopularService.getPopularData().data.contents
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package co.kr.bemyplan.data.repository.main.home

import co.kr.bemyplan.data.api.HomeSuggestService
import co.kr.bemyplan.domain.model.main.home.HomeDomainData
import co.kr.bemyplan.domain.repository.HomeSuggestRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import javax.inject.Inject

class HomeSuggestRepositoryImpl @Inject constructor(
private val homeSuggestService: HomeSuggestService,
private val coroutineDispatcher: CoroutineDispatcher
) : HomeSuggestRepository {
override suspend fun getHomeSuggestData(): List<HomeDomainData> {
return withContext(coroutineDispatcher){
homeSuggestService.getSuggestData().data.contents
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ class LocationRepositoryImpl @Inject constructor(
locationservice.getLocation().data
}
}

}
33 changes: 33 additions & 0 deletions app/src/main/java/co/kr/bemyplan/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import co.kr.bemyplan.data.repository.list.SuggestListRepositoryImpl
import co.kr.bemyplan.data.repository.list.UserPostListRepositoryImpl
import co.kr.bemyplan.data.repository.login.GoogleLoginRepositoryImpl
import co.kr.bemyplan.data.repository.login.LoginRepositoryImpl
import co.kr.bemyplan.data.repository.main.home.HomeNewRepositoryImpl
import co.kr.bemyplan.data.repository.main.home.HomePopularRepositoryImpl
import co.kr.bemyplan.data.repository.main.home.HomeSuggestRepositoryImpl
import co.kr.bemyplan.data.repository.main.location.LocationRepositoryImpl
import co.kr.bemyplan.data.repository.main.myplan.MyPlanRepository
import co.kr.bemyplan.data.repository.main.myplan.MyPlanRepositoryImpl
Expand Down Expand Up @@ -142,6 +145,36 @@ object RepositoryModule {
@IoDispatcher coroutineDispatcher: CoroutineDispatcher
): PurchaseRepository = PurchaseRepositoryImpl(purchaseService, coroutineDispatcher)

//홈뷰 인기 일정
@ViewModelScoped
@Provides
fun provideHomePopularRepository(
homePopularService: HomePopularService,
@IoDispatcher coroutineDispatcher: CoroutineDispatcher
) : HomePopularRepository{
return HomePopularRepositoryImpl(homePopularService, coroutineDispatcher)
}

//홈뷰 최신 일정
@ViewModelScoped
@Provides
fun provideHomeNewRepository(
homeNewService: HomeNewService,
@IoDispatcher coroutineDispatcher: CoroutineDispatcher
) : HomeNewRepository{
return HomeNewRepositoryImpl(homeNewService, coroutineDispatcher)
}

//홈뷰 추천 일정
@ViewModelScoped
@Provides
fun provideHomeSuggestRepository(
homeSuggestService: HomeSuggestService,
@IoDispatcher coroutineDispatcher: CoroutineDispatcher
) : HomeSuggestRepository{
return HomeSuggestRepositoryImpl(homeSuggestService, coroutineDispatcher)
}

// ?? 뭐지 왜 없는데 됐었지...?
// @ViewModelScoped
// @Provides
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/co/kr/bemyplan/di/ServiceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,25 @@ object ServiceModule {
fun providePurchaseService(@BeMyPlanRetrofit retrofit: Retrofit): PurchaseService {
return retrofit.create(PurchaseService::class.java)
}

//홈뷰 인기 일정
@Singleton
@Provides
fun provideHomePopularService(@BeMyPlanRetrofit retrofit: Retrofit):HomePopularService{
return retrofit.create(HomePopularService::class.java)
}

//홈뷰 최신 일정
@Singleton
@Provides
fun provideHomeNewService(@BeMyPlanRetrofit retrofit: Retrofit):HomeNewService{
return retrofit.create(HomeNewService::class.java)
}

//홈뷰 추천 일정
@Singleton
@Provides
fun provideHomeSuggestService(@BeMyPlanRetrofit retrofit: Retrofit):HomeSuggestService{
return retrofit.create(HomeSuggestService::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package co.kr.bemyplan.domain.model.main.home

data class HomeDomainData(
val createdAt : String,
val orderStatus : Boolean,
val planId: Int,
val scrapStatus : Boolean,
val thumbnailUrl: String,
val title: String,
val updatedAt : String,
val user : UserData,
){
data class UserData(
val nickname : String,
val userId : Int
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package co.kr.bemyplan.domain.repository

import co.kr.bemyplan.domain.model.main.home.HomeDomainData

interface HomeNewRepository {
suspend fun getHomeNewData():List<HomeDomainData>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package co.kr.bemyplan.domain.repository

import co.kr.bemyplan.domain.model.main.home.HomeDomainData

interface HomePopularRepository {
suspend fun getHomePopularData():List<HomeDomainData>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package co.kr.bemyplan.domain.repository

import co.kr.bemyplan.domain.model.main.home.HomeDomainData

interface HomeSuggestRepository {
suspend fun getHomeSuggestData():List<HomeDomainData>
}
14 changes: 7 additions & 7 deletions app/src/main/java/co/kr/bemyplan/ui/main/home/HomeAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import co.kr.bemyplan.data.entity.main.home.ResponseHomeData
import co.kr.bemyplan.databinding.ItemHomePlanBinding
import co.kr.bemyplan.domain.model.main.home.HomeDomainData
import co.kr.bemyplan.util.clipTo

class HomeAdapter(
val beforePurchase: (Int, Boolean) -> Unit,
val afterPurchase: (Int) -> Unit) : RecyclerView.Adapter<HomeAdapter.HomeViewHolder>() {

val planList = mutableListOf<ResponseHomeData.ResponseHomeItems.HomeData>()
val planList = mutableListOf<HomeDomainData>()

inner class HomeViewHolder(private val binding: ItemHomePlanBinding):RecyclerView.ViewHolder(binding.root){
fun onBind(data: ResponseHomeData.ResponseHomeItems.HomeData){
fun onBind(data: HomeDomainData){
binding.homeItem = data
clipTo(binding.ivHomeCommon, data.thumbnailUrl)
clickItem(data)
}

private fun clickItem(data: ResponseHomeData.ResponseHomeItems.HomeData) {
private fun clickItem(data: HomeDomainData) {
binding.root.setOnClickListener {
if (data.isPurchased == true) {
afterPurchase(data.postId)
if (data.orderStatus == true) {
afterPurchase(data.planId)
} else {
beforePurchase(data.postId, data.isScraped)
beforePurchase(data.planId, data.scrapStatus)
}
}
}
Expand Down
Loading

0 comments on commit e99b3b4

Please sign in to comment.