Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE-120] 약속현황 화면 구현 #128

Merged
merged 14 commits into from
Jul 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object Versions {
const val COMPOSE_ACTIVITY = "1.4.0"
const val COMPOSE_CONSTRAINT_LAYOUT = "1.1.0-alpha02"
const val CONSTRAINT_LAYOUT = "2.1.3"
const val COMPOSE_NAVIGATION = "2.4.2"
const val COMPOSE_NAVIGATION = "2.5.0"
const val FIREBASE_BOM = "29.1.0"
const val FIREBASE_CRASHLYTICS = "2.9.0"
const val GOOGLE_SERVICE = "4.3.10"
Expand All @@ -18,7 +18,7 @@ object Versions {
const val JUNIT = "4.13.2"
const val KAKAO_SDK = "2.11.0"
const val KOTLIN = "1.6.21"
const val KOTLIN_COROUTINES = "1.5.1"
const val KOTLIN_COROUTINES = "1.6.4"
const val KOTLIN_DATETIMES = "0.4.0"
const val MATERIAL_CALENDAR = "1.4.3"
const val LIFECYCLE = "2.4.1"
Expand Down
18 changes: 11 additions & 7 deletions data/src/main/java/com/yapp/growth/data/api/GrowthApi.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.yapp.growth.data.api

import com.yapp.growth.data.internal.response.*
import com.yapp.growth.data.parameter.ConfirmPlanParameter
import com.yapp.growth.data.parameter.FixPlanParameter
import com.yapp.growth.data.parameter.TemporaryPlanParameter
import com.yapp.growth.data.parameter.TimeCheckedOfDaysParameter
import com.yapp.growth.data.response.UserResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
Expand All @@ -31,25 +30,30 @@ interface GrowthApi {
): TimeRequestResponseImpl

@POST("/api/promisings/{promisingId}/confirmation")
suspend fun sendConfirmPlan(
@Path("promisingId") promisingId: String,
@Body confirmPlanParameter: ConfirmPlanParameter,
suspend fun sendFixPlan(
@Path("promisingId") planId: String,
@Body fixPlanParameter: FixPlanParameter,
): Any

@POST("/api/promisings/{promisingId}/time-response")
suspend fun sendRespondPlan(
@Path("promisingId") promisingId: String,
@Path("promisingId") planId: String,
@Body timeCheckedOfDaysParameter: TimeCheckedOfDaysParameter,
)

@POST("/api/promisings/{promisingId}/time-response/rejection")
suspend fun sendRejectPlan(
@Path("promisingId") planId: String
)

@GET("/api/promisings/user")
suspend fun getWaitingPlans(): List<WaitingPlanResponseImpl>

// Fixed Plans

@GET("/api/promises/{promiseId}")
suspend fun getFixedPlan(
@Path("promiseId") pId: Long,
@Path("promiseId") planId: Long,
): FixedPlanResponseImpl

@GET("/api/promises/user")
Expand Down
10 changes: 5 additions & 5 deletions data/src/main/java/com/yapp/growth/data/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.yapp.growth.data.di

import com.yapp.growth.data.repository.ConfirmPlanRepositoryImpl
import com.yapp.growth.data.repository.FixPlanRepositoryImpl
import com.yapp.growth.data.repository.CreateTimeTableRepositoryImpl
import com.yapp.growth.data.repository.LoadPlanRepositoryImpl
import com.yapp.growth.data.repository.TemporaryPlanRepositoryImpl
import com.yapp.growth.domain.repository.ConfirmPlanRepository
import com.yapp.growth.domain.repository.FixPlanRepository
import com.yapp.growth.domain.repository.TemporaryPlanRepository
import com.yapp.growth.domain.repository.CreateTimeTableRepository
import com.yapp.growth.domain.repository.LoadPlanRepository
Expand All @@ -30,9 +30,9 @@ internal abstract class RepositoryModule {
): TemporaryPlanRepository

@Binds
abstract fun bindConfirmPlanRepository(
confirmPlanRepository: ConfirmPlanRepositoryImpl,
): ConfirmPlanRepository
abstract fun bindFixPlanRepository(
fixPlanRepository: FixPlanRepositoryImpl,
): FixPlanRepository

@Binds
abstract fun bindDetailRepository(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ data class WaitingPlanResponseImpl(
override val members: List<UserResponseImpl>,
@Json(name = "placeName")
override val place: String,
@Json(name = "isResponsed")
override val isAlreadyReplied: Boolean,
) : WaitingPlanResponse
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.yapp.growth.data.internal.source
import com.yapp.growth.data.api.GrowthApi
import com.yapp.growth.data.api.handleApi
import com.yapp.growth.data.mapper.*
import com.yapp.growth.data.parameter.ConfirmPlanParameter
import com.yapp.growth.data.parameter.FixPlanParameter
import com.yapp.growth.data.parameter.TemporaryPlanParameter
import com.yapp.growth.data.parameter.TimeCheckedOfDayParameter
import com.yapp.growth.data.parameter.TimeCheckedOfDaysParameter
Expand Down Expand Up @@ -38,13 +38,13 @@ internal class PlanzDataSourceImpl @Inject constructor(
retrofitApi.makePlan(uuid, parameter).toLong()
}

override suspend fun getRespondUsers(promisingId: Long): NetworkResult<TimeTable> =
override suspend fun getRespondUsers(planId: Long): NetworkResult<TimeTable> =
handleApi {
retrofitApi.getResponseTimeTable(promisingId.toString()).toTimeTable()
retrofitApi.getResponseTimeTable(planId.toString()).toTimeTable()
}

override suspend fun sendRespondPlan(
promisingId: Long,
planId: Long,
timeCheckedOfDays: List<TimeCheckedOfDay>
): NetworkResult<Unit> =
handleApi {
Expand All @@ -57,12 +57,17 @@ internal class PlanzDataSourceImpl @Inject constructor(
)
}
)
retrofitApi.sendRespondPlan(promisingId.toString(), parameter)
retrofitApi.sendRespondPlan(planId.toString(), parameter)
}

override suspend fun sendConfirmPlan(promisingId: Long, date: String): NetworkResult<Any> =
override suspend fun sendRejectPlan(planId: Long): NetworkResult<Unit> =
handleApi {
retrofitApi.sendConfirmPlan(promisingId.toString(), ConfirmPlanParameter(date))
retrofitApi.sendRejectPlan(planId.toString())
}

override suspend fun sendFixPlan(planId: Long, date: String): NetworkResult<Any> =
handleApi {
retrofitApi.sendFixPlan(planId.toString(), FixPlanParameter(date))
}

override suspend fun getFixedPlans(): NetworkResult<List<Plan.FixedPlan>> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.yapp.growth.data.mapper
import com.yapp.growth.data.response.WaitingPlanResponse
import com.yapp.growth.domain.entity.Plan

fun WaitingPlanResponse.toWaitingPlan(isAlreadyReplied: Boolean = false): Plan.WaitingPlan {
fun WaitingPlanResponse.toWaitingPlan(): Plan.WaitingPlan {
return Plan.WaitingPlan(
id = id,
title = title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.yapp.growth.data.parameter

data class ConfirmPlanParameter(
data class FixPlanParameter(
val promiseDate: String
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.yapp.growth.data.repository

import com.yapp.growth.data.source.PlanzDataSource
import com.yapp.growth.domain.NetworkResult
import com.yapp.growth.domain.entity.TimeTable
import com.yapp.growth.domain.repository.FixPlanRepository
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
internal class FixPlanRepositoryImpl @Inject constructor(
private val dataSource: PlanzDataSource
) : FixPlanRepository {

override suspend fun getRespondUsers(planId: Long): NetworkResult<TimeTable> {
return dataSource.getRespondUsers(planId)
}

override suspend fun sendFixPlan(planId: Long, date: String): NetworkResult<Any> {
return dataSource.sendFixPlan(planId, date)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ internal class RespondPlanRepositoryImpl @Inject constructor(
): RespondPlanRepository {

override suspend fun sendRespondPlan(
promisingId: Long,
planId: Long,
timeCheckedOfDays: List<TimeCheckedOfDay>
): NetworkResult<Unit> {
return datasource.sendRespondPlan(promisingId, timeCheckedOfDays)
return datasource.sendRespondPlan(planId, timeCheckedOfDays)
}

override suspend fun sendRejectPlan(planId: Long): NetworkResult<Unit> {
return datasource.sendRejectPlan(planId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ interface WaitingPlanResponse {
val availableDates: List<String>
val members: List<UserResponse>
val place: String
val isAlreadyReplied: Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ interface PlanzDataSource {
suspend fun getCreateTimeTable(uuid: String): NetworkResult<CreateTimeTable>
suspend fun makePlan(uuid: String, timeCheckedOfDays: List<TimeCheckedOfDay>): NetworkResult<Long>

suspend fun getRespondUsers(promisingId: Long): NetworkResult<TimeTable>
suspend fun sendRespondPlan(promisingId: Long, timeCheckedOfDays: List<TimeCheckedOfDay>): NetworkResult<Unit>
suspend fun sendConfirmPlan(promisingId: Long, date: String): NetworkResult<Any>
suspend fun getRespondUsers(planId: Long): NetworkResult<TimeTable>
suspend fun sendRespondPlan(planId: Long, timeCheckedOfDays: List<TimeCheckedOfDay>): NetworkResult<Unit>

suspend fun sendRejectPlan(planId: Long): NetworkResult<Unit>
suspend fun sendFixPlan(planId: Long, date: String): NetworkResult<Any>

suspend fun getWaitingPlans(): NetworkResult<List<Plan.WaitingPlan>>
suspend fun getFixedPlans(): NetworkResult<List<Plan.FixedPlan>>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.yapp.growth.domain.repository

import com.yapp.growth.domain.NetworkResult
import com.yapp.growth.domain.entity.TimeTable

interface FixPlanRepository {

suspend fun getRespondUsers(planId: Long): NetworkResult<TimeTable>

suspend fun sendFixPlan(planId: Long, date: String): NetworkResult<Any>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import com.yapp.growth.domain.NetworkResult
import com.yapp.growth.domain.entity.TimeCheckedOfDay

interface RespondPlanRepository {
suspend fun sendRespondPlan(promisingId: Long, timeCheckedOfDays: List<TimeCheckedOfDay>): NetworkResult<Unit>
suspend fun sendRespondPlan(planId: Long, timeCheckedOfDays: List<TimeCheckedOfDay>): NetworkResult<Unit>
suspend fun sendRejectPlan(planId: Long): NetworkResult<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package com.yapp.growth.domain.usecase

import com.yapp.growth.domain.NetworkResult
import com.yapp.growth.domain.entity.TimeTable
import com.yapp.growth.domain.repository.ConfirmPlanRepository
import com.yapp.growth.domain.repository.FixPlanRepository
import javax.inject.Inject

class GetRespondUsersUseCase @Inject constructor(
private val repository: ConfirmPlanRepository
private val repository: FixPlanRepository
) {
suspend operator fun invoke(promisingId: Long): NetworkResult<TimeTable> {
return repository.getRespondUsers(promisingId)
suspend operator fun invoke(planId: Long): NetworkResult<TimeTable> {
return repository.getRespondUsers(planId)
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.yapp.growth.domain.usecase

import com.yapp.growth.domain.NetworkResult
import com.yapp.growth.domain.repository.FixPlanRepository
import javax.inject.Inject

class SendFixPlanUseCase @Inject constructor(
private val repository: FixPlanRepository
) {
suspend operator fun invoke(planId: Long, date: String): NetworkResult<Any> {
return repository.sendFixPlan(planId, date)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.yapp.growth.domain.usecase

import com.yapp.growth.domain.NetworkResult
import com.yapp.growth.domain.repository.RespondPlanRepository
import javax.inject.Inject

class SendRejectPlanUseCase @Inject constructor(
private val repository: RespondPlanRepository
) {
suspend operator fun invoke(planId: Long): NetworkResult<Unit> {
return repository.sendRejectPlan(planId)
}
}
Loading