-
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 #71 from YAPP-Github/feature/TNT-181
[TNT-181] ํธ๋ ์ด๋ ํ ํ๋ฉด ์ผ๋ณ ๊ธฐ๋ก UI ๊ตฌํ
- Loading branch information
Showing
16 changed files
with
675 additions
and
90 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
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
82 changes: 82 additions & 0 deletions
82
data/network/src/main/java/co/kr/data/network/model/trainee/DailyRecordResponse.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,82 @@ | ||
package co.kr.data.network.model.trainee | ||
|
||
import co.kr.tnt.domain.model.RecordType | ||
import co.kr.tnt.domain.model.RecordType.ExerciseType | ||
import co.kr.tnt.domain.model.RecordType.MealType | ||
import co.kr.tnt.domain.model.trainee.DailyRecord | ||
import co.kr.tnt.domain.model.trainee.PtSession | ||
import co.kr.tnt.domain.model.trainee.TraineeDailyRecord | ||
import co.kr.tnt.domain.utils.DateFormatter | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class DailyRecordsResponse( | ||
val date: String, | ||
val lessons: PtSessionResponse?, | ||
val records: List<RecordResponse>, | ||
) | ||
|
||
@Serializable | ||
data class PtSessionResponse( | ||
val ptSessionId: String, | ||
val trainerName: String, | ||
val trainerImage: String?, | ||
val session: Int, | ||
val startTime: String, | ||
val endTime: String, | ||
val hasRecord: Boolean, | ||
) | ||
|
||
@Serializable | ||
data class RecordResponse( | ||
val recordId: String, | ||
val recordType: String, | ||
val recordTime: String, | ||
val recordImage: String?, | ||
val recordContents: String, | ||
val feedbackCount: Int, | ||
) | ||
|
||
fun DailyRecordsResponse.toDomain(dateFormatter: DateFormatter) = | ||
TraineeDailyRecord( | ||
date = dateFormatter.parse(date), | ||
ptSession = lessons?.toDomain(dateFormatter), | ||
record = records.map { it.toDomain(dateFormatter) }, | ||
) | ||
|
||
fun PtSessionResponse.toDomain(dateFormatter: DateFormatter) = PtSession( | ||
ptSessionId = ptSessionId, | ||
trainerName = trainerName, | ||
trainerImage = trainerImage, | ||
session = session, | ||
startTime = dateFormatter.parseDateTime(startTime), | ||
endTime = dateFormatter.parseDateTime(endTime), | ||
hasRecord = hasRecord, | ||
) | ||
|
||
fun RecordResponse.toDomain(dateFormatter: DateFormatter) = DailyRecord( | ||
recordId = recordId, | ||
recordType = recordType.toRecordType() ?: MealType.BREAKFAST, | ||
recordTime = dateFormatter.parseDateTime(recordTime), | ||
recordImage = recordImage, | ||
recordContents = recordContents, | ||
feedbackCount = feedbackCount, | ||
) | ||
|
||
// TODO : ์์ | ||
fun String.toRecordType(): RecordType? { | ||
return when (this.uppercase()) { | ||
"BREAKFAST" -> MealType.BREAKFAST | ||
"LUNCH" -> MealType.LUNCH | ||
"DINNER" -> MealType.DINNER | ||
"SNACK" -> MealType.SNACK | ||
|
||
"UPPER_BODY" -> ExerciseType.UPPER_BODY | ||
"LOWER_BODY" -> ExerciseType.LOWER_BODY | ||
"BACK" -> ExerciseType.BACK | ||
"SHOULDER" -> ExerciseType.SHOULDER | ||
"CARDIO" -> ExerciseType.CARDIO | ||
|
||
else -> null | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
data/network/src/main/java/co/kr/data/network/model/trainee/MonthlyRecordStateResponse.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 co.kr.data.network.model.trainee | ||
|
||
import co.kr.tnt.domain.model.trainee.TraineeDailyRecordStatus | ||
import co.kr.tnt.domain.utils.DateFormatter | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class MonthlyRecordedDatesResponse( | ||
val calendarRecordInfo: List<RecordedDateResponse>, | ||
) | ||
|
||
@Serializable | ||
data class RecordedDateResponse( | ||
val date: String, | ||
) | ||
|
||
fun RecordedDateResponse.toDomain(dateFormatter: DateFormatter) = | ||
TraineeDailyRecordStatus( | ||
date = dateFormatter.parse(date), | ||
) |
169 changes: 169 additions & 0 deletions
169
data/repository/src/main/java/co/kr/data/repository/TraineeRepositoryImpl.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,169 @@ | ||
package co.kr.data.repository | ||
|
||
import co.kr.data.network.model.trainee.DailyRecordsResponse | ||
import co.kr.data.network.model.trainee.MonthlyRecordedDatesResponse | ||
import co.kr.data.network.model.trainee.PtSessionResponse | ||
import co.kr.data.network.model.trainee.RecordResponse | ||
import co.kr.data.network.model.trainee.RecordedDateResponse | ||
import co.kr.data.network.model.trainee.toDomain | ||
import co.kr.tnt.domain.model.trainee.TraineeDailyRecord | ||
import co.kr.tnt.domain.model.trainee.TraineeDailyRecordStatus | ||
import co.kr.tnt.domain.repository.TraineeRepository | ||
import co.kr.tnt.domain.utils.DateFormatter | ||
import java.time.LocalDate | ||
import java.time.YearMonth | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
internal class TraineeRepositoryImpl @Inject constructor( | ||
private val dateFormatter: DateFormatter, | ||
) : TraineeRepository { | ||
// TODO : API์ ๋ง์ถฐ ์์ | ||
override suspend fun getDailyDataStatus(yearMonth: YearMonth): List<TraineeDailyRecordStatus> { | ||
val result = MonthlyRecordedDatesResponse( | ||
listOf( | ||
RecordedDateResponse(date = "2025-02-03"), | ||
RecordedDateResponse(date = "2025-02-08"), | ||
RecordedDateResponse(date = "2025-02-10"), | ||
RecordedDateResponse(date = "2025-02-15"), | ||
RecordedDateResponse(date = "2025-02-23"), | ||
), | ||
).calendarRecordInfo.map { response -> | ||
response.toDomain(dateFormatter) | ||
} | ||
|
||
return result | ||
} | ||
|
||
override suspend fun getTraineeDailyRecord(day: LocalDate): TraineeDailyRecord { | ||
val result = listOf( | ||
DailyRecordsResponse( | ||
date = "2025-02-03", | ||
lessons = PtSessionResponse( | ||
ptSessionId = "CDE35K32", | ||
trainerName = "๊นํฌ์ค", | ||
trainerImage = "https://buly.kr/44x6xFN", | ||
session = 12, | ||
startTime = "2025-02-03T08:00:00.000Z", | ||
endTime = "2025-02-03T09:00:00.000Z", | ||
hasRecord = true, | ||
), | ||
records = listOf( | ||
RecordResponse( | ||
recordId = "VDF1D907", | ||
recordType = "BREAKFAST", | ||
recordTime = "2025-02-03T08:00:00.000Z", | ||
recordImage = "https://buly.kr/BpESNP5", | ||
recordContents = "์์นจ์ผ๋ก ๊ณ๋ 2๊ฐ ๋จน์์ต๋๋ค.", | ||
feedbackCount = 1, | ||
), | ||
RecordResponse( | ||
recordId = "VDF1D907", | ||
recordType = "LUNCH", | ||
recordTime = "2025-02-03T13:00:00.000Z", | ||
recordImage = "https://buly.kr/BpESNP5", | ||
recordContents = "์ ์ฌ์ผ๋ก ๊ณ๋ 5๊ฐ ๋จน์์ต๋๋ค.", | ||
feedbackCount = 0, | ||
), | ||
), | ||
), | ||
DailyRecordsResponse( | ||
date = "2025-02-08", | ||
lessons = null, | ||
records = listOf( | ||
RecordResponse( | ||
recordId = "VDF1D907", | ||
recordType = "BREAKFAST", | ||
recordTime = "2025-02-08T13:00:00.000Z", | ||
recordImage = "https://buly.kr/BpESNP5", | ||
recordContents = "๊ณ๋ 2๊ฐ ๋จน์์ต๋๋ค.", | ||
feedbackCount = 1, | ||
), | ||
RecordResponse( | ||
recordId = "VDF1D907", | ||
recordType = "SNACK", | ||
recordTime = "2025-02-08T15:00:00.000Z", | ||
recordImage = "https://buly.kr/BpESNP5", | ||
recordContents = "๊ณ๋ ๋ฐ๊ฐ ๋จน์์ต๋๋ค.", | ||
feedbackCount = 0, | ||
), | ||
RecordResponse( | ||
recordId = "VDF1D907", | ||
recordType = "DINNER", | ||
recordTime = "2025-02-08T18:40:00.000Z", | ||
recordImage = null, | ||
recordContents = "์ ๋ ์ผ๋ก ์๊ณ ๊ธฐ ๋จน์์ต๋๋ค.", | ||
feedbackCount = 2, | ||
), | ||
), | ||
), | ||
DailyRecordsResponse( | ||
date = "2025-02-15", | ||
lessons = PtSessionResponse( | ||
ptSessionId = "OSI93DG1", | ||
trainerName = "์ด๊ฐ์ฌ", | ||
trainerImage = null, | ||
session = 15, | ||
startTime = "2025-02-15T18:00:00.000Z", | ||
endTime = "2025-02-15T19:00:00.000Z", | ||
hasRecord = true, | ||
), | ||
records = listOf( | ||
RecordResponse( | ||
recordId = "VDF1D907", | ||
recordType = "LUNCH", | ||
recordTime = "2025-02-15T13:00:00.000Z", | ||
recordImage = null, | ||
recordContents = "๋น๋น๋ฐฅ, ๋ฐ๋๋ 1๊ฐ", | ||
feedbackCount = 1, | ||
), | ||
RecordResponse( | ||
recordId = "VDF1D907", | ||
recordType = "DINNER", | ||
recordTime = "2025-02-03T20:00:00.000Z", | ||
recordImage = "https://buly.kr/BpESNP5", | ||
recordContents = "๊ณ๋ 5๊ฐ ๋จน์์ต๋๋ค.", | ||
feedbackCount = 0, | ||
), | ||
), | ||
), | ||
DailyRecordsResponse( | ||
date = "2025-02-10", | ||
lessons = PtSessionResponse( | ||
ptSessionId = "CDK392DF", | ||
trainerName = "๋ฐํธ๋ ์ด๋", | ||
trainerImage = null, | ||
session = 10, | ||
startTime = "2025-02-10T14:30:00.000Z", | ||
endTime = "2025-02-10T15:30:00.000Z", | ||
hasRecord = false, | ||
), | ||
records = emptyList(), | ||
), | ||
DailyRecordsResponse( | ||
date = "2025-02-23", | ||
lessons = PtSessionResponse( | ||
ptSessionId = "CDE35K32", | ||
trainerName = "์ ํธ๋ ์ด๋", | ||
trainerImage = "https://buly.kr/44x6xFN", | ||
session = 25, | ||
startTime = "2025-02-23T06:00:00.000Z", | ||
endTime = "2025-02-23T06:50:00.000Z", | ||
hasRecord = true, | ||
), | ||
records = emptyList(), | ||
), | ||
).map { response -> | ||
response.toDomain(dateFormatter) | ||
}.firstOrNull { it.date == day } | ||
|
||
val noData = TraineeDailyRecord( | ||
date = day, | ||
ptSession = null, | ||
record = emptyList(), | ||
) | ||
|
||
return result ?: noData | ||
} | ||
} |
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
Oops, something went wrong.