Skip to content

Commit

Permalink
[FEAT] #262 마이페이지 구매목록 페이징 작업중 - 현재 포스트맨에서 페이징 안됨 + 내가 코드를 잘못짜서 무한 서버…
Browse files Browse the repository at this point in the history
…통신됨 currentlist.size계속 커지다 터짐
  • Loading branch information
briandr97 committed Jun 3, 2022
1 parent fe55e72 commit 64f0edc
Show file tree
Hide file tree
Showing 28 changed files with 196 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import retrofit2.http.Body
import retrofit2.http.POST

interface GoogleLoginService {
@POST("/oauth2/v4/token")
@POST("oauth2/v4/token")
suspend fun postGoogleSignInData(
@Body body: RequestGoogleLogin
): ResponseGoogleLogin
Expand Down
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("/v1/plans?size=10&sort=createdAt,desc")
@GET("v1/plans?size=10&sort=createdAt,desc")
suspend fun getNewData() : 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 HomePopularService {
@GET("/v1/plans?size=10&sort=orderCnt,desc")
@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("/v1/plans/bemyplanPick?size=5&sort=id,desc")
@GET("v1/plans/bemyplanPick?size=5&sort=id,desc")
suspend fun getSuggestData(): ResponseHomeData
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import retrofit2.http.GET
import retrofit2.http.Query

interface LocationListService {
@GET("/v1/plans")
@GET("v1/plans")
suspend fun fetchLocationList(
@Query("region") region: String,
@Query("size") size: Int,
@Query("sort", encoded = true) sort: String
): ResponseLocationList

@GET("/v1/plans")
@GET("v1/plans")
suspend fun fetchMoreLocationList(
@Query("region") region: String,
@Query("size") size: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import retrofit2.Call
import retrofit2.http.GET

interface LocationService {
@GET("/v1/plan/regions")
@GET("v1/plan/regions")
suspend fun getLocation() : ResponseLocationData
}
6 changes: 3 additions & 3 deletions app/src/main/java/co/kr/bemyplan/data/api/LoginService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import retrofit2.http.POST
import retrofit2.http.Query

interface LoginService {
@POST("/v1/login")
@POST("v1/login")
suspend fun postLogin(
@Body body: RequestLogin
): ResponseLogin

@GET("/v1/user/name/check")
@GET("v1/user/name/check")
suspend fun postDuplicatedNickname(
@Query("nickname") nickname: String
): ResponseDuplicatedNickname

@POST("/v1/signup")
@POST("v1/signup")
suspend fun postSignUp(
@Body body: RequestSignUp
): ResponseSignUp
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/java/co/kr/bemyplan/data/api/MyPlanService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ package co.kr.bemyplan.data.api

import co.kr.bemyplan.data.entity.main.myplan.ResponseMyPlan
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

interface MyPlanService {
@GET("api/v1/order")
@GET("v1/plan/orders")
suspend fun getMyPlan(
@Query("page") page: Int,
@Query("pageSize") pageSize: Int
@Query("size") size: Int
): ResponseMyPlan

@GET("v1/plan/orders")
suspend fun getMoreMyPlan(
@Query("size") size: Int,
@Query("lastPlanId") lastPlanId: Int
): ResponseMyPlan
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import retrofit2.http.GET
import retrofit2.http.Path

interface PreviewService {
@GET("/v1/plan/{planId}/preview")
@GET("v1/plan/{planId}/preview")
suspend fun fetchPreviewPlan(
@Path("planId") planId: Int
): ResponsePreviewPlan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import retrofit2.http.Body
import retrofit2.http.POST

interface PurchaseService {
@POST("/v1/plan/order")
@POST("v1/plan/order")
suspend fun purchase(
@Body requestBody: RequestPurchase
): ResponsePurchase
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/co/kr/bemyplan/data/api/ScrapListService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import retrofit2.http.Path
import retrofit2.http.Query

interface ScrapListService {
@GET("/v1/plan/bookmark")
@GET("v1/plan/bookmark")
suspend fun getScrapList(
@Query("size") page: Int,
@Query("sort", encoded = true) sort: String
): ResponseScrapList

@GET("api/v1/post/random")
@GET("v1/post/random")
suspend fun getEmptyScrapList(): ResponseEmptyScrapList
}
4 changes: 2 additions & 2 deletions app/src/main/java/co/kr/bemyplan/data/api/ScrapService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import retrofit2.http.POST
import retrofit2.http.Path

interface ScrapService {
@POST("/v1/plan/scrap/{planId}")
@POST("v1/plan/scrap/{planId}")
suspend fun postScrap(
@Path("planId") planId: Int
): ResponseScrap

@DELETE("/v1/plan/scrap/{planId}")
@DELETE("v1/plan/scrap/{planId}")
suspend fun deleteScrap(
@Path("planId") planId: Int
): ResponseScrap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import retrofit2.http.GET
import retrofit2.http.Query

interface SuggestListService {
@GET("/v1/plans/bemyplanPick")
@GET("v1/plans/bemyplanPick")
suspend fun fetchSuggestList(
@Query("size") size: Int
): ResponseSuggestList

@GET("/v1/plans/bemyplanPick")
@GET("v1/plans/bemyplanPick")
suspend fun fetchMoreSuggestList(
@Query("size") size: Int,
@Query("lastPlanId") lastPlanId: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import retrofit2.http.GET
import retrofit2.http.Query

interface UserPlanListService {
@GET("/v1/plans")
@GET("v1/plans")
suspend fun fetchUserPlanList(
@Query("size") size: Int,
@Query("sort") sort: String,
@Query("userId") userId: Int
): ResponseUserPlanList

@GET("/v1/plans")
@GET("v1/plans")
suspend fun fetchMoreUserPlanList(
@Query("size") size: Int,
@Query("sort") sort: String,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package co.kr.bemyplan.data.entity.main.myplan

import co.kr.bemyplan.domain.model.main.myplan.MyPlanData

data class ResponseMyPlan(
val data: Data
) {
data class Data(
val items: List<MyModel>,
val totalCount: Int,
val totalPage: Int
)
}
val data : MyPlanData,
val message : String,
val resultCode : String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package co.kr.bemyplan.data.entity.main.myplan

data class User(
val nickname: String,
val userId: Int
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
package co.kr.bemyplan.data.repository.main.myplan

import co.kr.bemyplan.data.api.ApiService
import co.kr.bemyplan.data.api.MyPlanService
import co.kr.bemyplan.data.entity.main.myplan.ResponseMyPlan
import kotlinx.coroutines.Dispatchers
import co.kr.bemyplan.domain.model.main.myplan.MyPlanData
import co.kr.bemyplan.domain.repository.MyPlanRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import javax.inject.Inject

class MyPlanRepositoryImpl @Inject constructor(
private val service: MyPlanService
): MyPlanRepository {
override suspend fun getMyPlan(page: Int, pageSize: Int): ResponseMyPlan {
return withContext(Dispatchers.IO) {
service.getMyPlan(page, pageSize)
private val myPlanService: MyPlanService,
private val coroutineDispatcher: CoroutineDispatcher
) : MyPlanRepository {
override suspend fun getMyPlan(size: Int): MyPlanData {
return withContext(coroutineDispatcher) {
myPlanService.getMyPlan(size).data
}
}

override suspend fun getMoreMyPlan(size: Int, lastPlanId: Int): MyPlanData {
return withContext(coroutineDispatcher) {
myPlanService.getMoreMyPlan(size, lastPlanId).data
}
}


}
21 changes: 11 additions & 10 deletions app/src/main/java/co/kr/bemyplan/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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.domain.repository.MyPlanRepository
import co.kr.bemyplan.data.repository.main.myplan.MyPlanRepositoryImpl
import co.kr.bemyplan.domain.repository.ScrapListRepository
import co.kr.bemyplan.data.repository.main.scrap.ScrapListRepositoryImpl
Expand Down Expand Up @@ -90,15 +90,6 @@ object RepositoryModule {
return UserPostListRepositoryImpl(userPlanListService, coroutineDispatcher)
}

// 마이페이지 뷰
@ViewModelScoped
@Provides
fun provideMyPlanRepository(
myPlanService: MyPlanService
): MyPlanRepository {
return MyPlanRepositoryImpl(myPlanService)
}

// 로그인 뷰
@ViewModelScoped
@Provides
Expand Down Expand Up @@ -177,6 +168,16 @@ object RepositoryModule {
return HomeSuggestRepositoryImpl(homeSuggestService, coroutineDispatcher)
}

//마이플랜 구매일정
@ViewModelScoped
@Provides
fun provideMyPlanRepository(
myPlanService: MyPlanService,
@IoDispatcher coroutineDispatcher: CoroutineDispatcher
) : MyPlanRepository{
return MyPlanRepositoryImpl(myPlanService, coroutineDispatcher)
}

// ?? 뭐지 왜 없는데 됐었지...?
// @ViewModelScoped
// @Provides
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/co/kr/bemyplan/di/ServiceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ object ServiceModule {
return retrofit.create(UserPlanListService::class.java)
}

// 마이페이지 뷰
@Singleton
@Provides
fun provideMyPlanService(@BeMyPlanRetrofit retrofit: Retrofit): MyPlanService {
return retrofit.create(MyPlanService::class.java)
}

// 로그인 뷰
@Singleton
@Provides
Expand Down Expand Up @@ -120,4 +113,11 @@ object ServiceModule {
fun provideHomeSuggestService(@BeMyPlanRetrofit retrofit: Retrofit):HomeSuggestService{
return retrofit.create(HomeSuggestService::class.java)
}

//마이페이지 구매일정
@Singleton
@Provides
fun provideMyPlanService(@BeMyPlanRetrofit retrofit: Retrofit):MyPlanService{
return retrofit.create(MyPlanService::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package co.kr.bemyplan.domain.model.main.myplan

import co.kr.bemyplan.data.entity.main.myplan.User

data class MyPlanData(
val contents: List<Data>,
val nextCursor: Int
){
data class Data(
val createdAt: String,
val orderStatus: Boolean,
val planId: Int,
val scrapStatus: Boolean,
val thumbnailUrl: String,
val title: String,
val updatedAt: String,
val user: User
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package co.kr.bemyplan.domain.repository

import co.kr.bemyplan.domain.model.main.myplan.MyPlanData

interface MyPlanRepository {
suspend fun getMyPlan(size: Int): MyPlanData
suspend fun getMoreMyPlan(size: Int, lastPlanId: Int): MyPlanData
}
Loading

0 comments on commit 64f0edc

Please sign in to comment.