-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from YAPP-Github/feature/issue-103-create-tim…
…etable [ISSUE-103] 약속생성 - 시간표 UI & Api 연동
- Loading branch information
Showing
30 changed files
with
778 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
package com.yapp.growth.data.api | ||
|
||
import com.yapp.growth.data.internal.response.CreateTimeTableResponseImpl | ||
import com.yapp.growth.data.internal.response.PromisingTimeTableResponseImpl | ||
import com.yapp.growth.data.internal.response.TimeRequestResponseImpl | ||
import com.yapp.growth.data.parameter.TimeRequestParameter | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
|
||
interface GrowthApi { | ||
|
||
@GET("/api/promisings/{promisingId}/time-table") | ||
suspend fun getResponseTimeTable(@Path("promisingId") promisingId: String): PromisingTimeTableResponseImpl | ||
|
||
@GET("/api/promisings/session/{uuid}") | ||
suspend fun getCreateTimeTable(@Path("uuid") uuid: String): CreateTimeTableResponseImpl | ||
|
||
@POST("/api/promisings/session/{uuid}/time-response") | ||
suspend fun sendTimeCheckedOfDay(@Path("uuid") uuid: String, @Body timeRequestParameter: TimeRequestParameter): TimeRequestResponseImpl | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
data/src/main/java/com/yapp/growth/data/internal/response/CreateTimeTableResponseImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.yapp.growth.data.internal.response | ||
|
||
import com.yapp.growth.data.response.CreateTimeTableResponse | ||
|
||
data class CreateTimeTableResponseImpl( | ||
override val minTime: String, | ||
override val maxTime: String, | ||
override val totalCount: Int, | ||
override val unit: Float, | ||
override val availableDates: List<String> | ||
): CreateTimeTableResponse |
8 changes: 8 additions & 0 deletions
8
data/src/main/java/com/yapp/growth/data/internal/response/TimeRequestResponseImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.yapp.growth.data.internal.response | ||
|
||
import com.yapp.growth.data.response.TimeRequestResponse | ||
|
||
data class TimeRequestResponseImpl( | ||
override val id: Long | ||
|
||
): TimeRequestResponse |
20 changes: 20 additions & 0 deletions
20
data/src/main/java/com/yapp/growth/data/internal/source/ConfirmPlanDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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.toTimeTable | ||
import com.yapp.growth.data.source.ConfirmPlanDataSource | ||
import com.yapp.growth.domain.NetworkResult | ||
import com.yapp.growth.domain.entity.TimeTable | ||
import javax.inject.Inject | ||
|
||
internal class ConfirmPlanDataSourceImpl @Inject constructor( | ||
private val retrofitApi: GrowthApi | ||
) : ConfirmPlanDataSource { | ||
|
||
override suspend fun getRespondUsers(promisingId: Long): NetworkResult<TimeTable> = | ||
handleApi { | ||
retrofitApi.getResponseTimeTable(promisingId.toString()).toTimeTable() | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
data/src/main/java/com/yapp/growth/data/internal/source/CreateTimeTableDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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.toCreateTimeTable | ||
import com.yapp.growth.data.mapper.toLong | ||
import com.yapp.growth.data.parameter.TimeCheckedOfDayParameter | ||
import com.yapp.growth.data.parameter.TimeRequestParameter | ||
import com.yapp.growth.data.source.CreateTimeTableDataSource | ||
import com.yapp.growth.domain.NetworkResult | ||
import com.yapp.growth.domain.entity.CreateTimeTable | ||
import com.yapp.growth.domain.entity.TimeCheckedOfDay | ||
import javax.inject.Inject | ||
|
||
internal class CreateTimeTableDataSourceImpl @Inject constructor( | ||
private val retrofitApi: GrowthApi | ||
): CreateTimeTableDataSource { | ||
|
||
override suspend fun getCreateTimeTable(uuid: String): NetworkResult<CreateTimeTable> = | ||
handleApi { | ||
retrofitApi.getCreateTimeTable(uuid).toCreateTimeTable() | ||
} | ||
|
||
override suspend fun sendTimeCheckedOfDay( | ||
uuid: String, | ||
timeCheckedOfDays: List<TimeCheckedOfDay> | ||
): NetworkResult<Long> = | ||
handleApi { | ||
val parameter = TimeRequestParameter( | ||
unit = 0.5f, | ||
timeTable = timeCheckedOfDays.map { | ||
TimeCheckedOfDayParameter( | ||
date = it.date, | ||
times = it.timeList | ||
) | ||
} | ||
) | ||
retrofitApi.sendTimeCheckedOfDay(uuid, parameter).toLong() | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
data/src/main/java/com/yapp/growth/data/mapper/CreateTimeTableResponseToModelMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.yapp.growth.data.mapper | ||
|
||
import com.yapp.growth.data.response.CreateTimeTableResponse | ||
import com.yapp.growth.data.response.TimeRequestResponse | ||
import com.yapp.growth.domain.entity.CreateTimeTable | ||
import com.yapp.growth.domain.entity.TimeCheckedOfDay | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
private val parseFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.KOREA) | ||
private val hourFormat = SimpleDateFormat("HH:mm", Locale.KOREA) | ||
|
||
fun CreateTimeTableResponse.toCreateTimeTable(): CreateTimeTable { | ||
val response = this | ||
return CreateTimeTable( | ||
totalCount = response.totalCount/2, | ||
minTime = response.minTime, | ||
maxTime = response.maxTime, | ||
availableDates = response.availableDates, | ||
hourList = makeHourList(response.minTime, response.totalCount/2), | ||
) | ||
} | ||
|
||
fun TimeRequestResponse.toLong(): Long { | ||
return this.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
data/src/main/java/com/yapp/growth/data/parameter/TimeRequestParameter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.yapp.growth.data.parameter | ||
|
||
data class TimeRequestParameter( | ||
val unit: Float, | ||
val timeTable: List<TimeCheckedOfDayParameter> | ||
) | ||
|
||
data class TimeCheckedOfDayParameter( | ||
val date: String, | ||
val times: List<Boolean> | ||
) |
27 changes: 27 additions & 0 deletions
27
data/src/main/java/com/yapp/growth/data/repository/CreateTimeTableRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.yapp.growth.data.repository | ||
|
||
import com.yapp.growth.data.source.CreateTimeTableDataSource | ||
import com.yapp.growth.domain.NetworkResult | ||
import com.yapp.growth.domain.entity.CreateTimeTable | ||
import com.yapp.growth.domain.entity.TimeCheckedOfDay | ||
import com.yapp.growth.domain.repository.CreateTimeTableRepository | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
internal class CreateTimeTableRepositoryImpl @Inject constructor( | ||
private val dataSource: CreateTimeTableDataSource | ||
): CreateTimeTableRepository { | ||
|
||
override suspend fun getCreateTimeTable(uuid: String): NetworkResult<CreateTimeTable> { | ||
return dataSource.getCreateTimeTable(uuid) | ||
} | ||
|
||
override suspend fun sendTimeCheckedOfDay( | ||
uuid: String, | ||
timeCheckedOfDays: List<TimeCheckedOfDay> | ||
): NetworkResult<Long> { | ||
return dataSource.sendTimeCheckedOfDay(uuid, timeCheckedOfDays) | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
data/src/main/java/com/yapp/growth/data/response/CreateTimeTableResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.yapp.growth.data.response | ||
|
||
interface CreateTimeTableResponse { | ||
val minTime: String | ||
val maxTime: String | ||
val totalCount: Int | ||
val unit: Float | ||
val availableDates: List<String> | ||
} |
5 changes: 5 additions & 0 deletions
5
data/src/main/java/com/yapp/growth/data/response/TimeRequestResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.yapp.growth.data.response | ||
|
||
interface TimeRequestResponse { | ||
val id: Long | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
data/src/main/java/com/yapp/growth/data/source/ConfirmPlanDataSourceImpl.kt
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
data/src/main/java/com/yapp/growth/data/source/CreateTimeTableDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.yapp.growth.data.source | ||
|
||
import com.yapp.growth.data.internal.response.TimeRequestResponseImpl | ||
import com.yapp.growth.domain.NetworkResult | ||
import com.yapp.growth.domain.entity.CreateTimeTable | ||
import com.yapp.growth.domain.entity.TimeCheckedOfDay | ||
|
||
interface CreateTimeTableDataSource { | ||
|
||
suspend fun getCreateTimeTable(uuid: String): NetworkResult<CreateTimeTable> | ||
|
||
suspend fun sendTimeCheckedOfDay(uuid: String, timeCheckedOfDays: List<TimeCheckedOfDay>): NetworkResult<Long> | ||
} |
9 changes: 9 additions & 0 deletions
9
domain/src/main/java/com/yapp/growth/domain/entity/CreateTimeTable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.yapp.growth.domain.entity | ||
|
||
data class CreateTimeTable( | ||
val totalCount: Int, | ||
val minTime: String, | ||
val maxTime: String, | ||
var availableDates: List<String>, | ||
val hourList: List<String>, | ||
) |
3 changes: 1 addition & 2 deletions
3
...owth/domain/entity/SendingResponsePlan.kt → .../growth/domain/entity/TimeCheckedOfDay.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package com.yapp.growth.domain.entity | ||
|
||
data class SendingResponsePlan( | ||
data class TimeCheckedOfDay( | ||
val date: String, | ||
val hours: List<String>, | ||
val timeList: MutableList<Boolean> | ||
) |
12 changes: 12 additions & 0 deletions
12
domain/src/main/java/com/yapp/growth/domain/repository/CreateTimeTableRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.yapp.growth.domain.repository | ||
|
||
import com.yapp.growth.domain.NetworkResult | ||
import com.yapp.growth.domain.entity.CreateTimeTable | ||
import com.yapp.growth.domain.entity.TimeCheckedOfDay | ||
|
||
interface CreateTimeTableRepository { | ||
|
||
suspend fun getCreateTimeTable(uuid: String): NetworkResult<CreateTimeTable> | ||
|
||
suspend fun sendTimeCheckedOfDay(uuid: String, timeCheckedOfDays: List<TimeCheckedOfDay>): NetworkResult<Long> | ||
} |
14 changes: 14 additions & 0 deletions
14
domain/src/main/java/com/yapp/growth/domain/usecase/GetCreateTimeTableUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.yapp.growth.domain.usecase | ||
|
||
import com.yapp.growth.domain.NetworkResult | ||
import com.yapp.growth.domain.entity.CreateTimeTable | ||
import com.yapp.growth.domain.repository.CreateTimeTableRepository | ||
import javax.inject.Inject | ||
|
||
class GetCreateTimeTableUseCase @Inject constructor( | ||
private val repository: CreateTimeTableRepository | ||
) { | ||
suspend operator fun invoke(uuid: String): NetworkResult<CreateTimeTable> { | ||
return repository.getCreateTimeTable(uuid) | ||
} | ||
} |
Oops, something went wrong.