-
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 #68 from YAPP-Github/feature/TNT-178
[TNT-178] ํธ๋ ์ด๋ ํํ๋ฉด ์บ๋ฆฐ๋ ๊ตฌํ
- Loading branch information
Showing
16 changed files
with
303 additions
and
45 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
22 changes: 22 additions & 0 deletions
22
.../network/src/main/java/co/kr/data/network/model/trainer/MonthlyPtSessionCountsResponse.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,22 @@ | ||
package co.kr.data.network.model.trainer | ||
|
||
import co.kr.tnt.domain.model.trainer.DailyPtSessionCount | ||
import co.kr.tnt.domain.utils.DateFormatter | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class MonthlyPtSessionCountsResponse( | ||
val calendarPtLessonCounts: List<PtSessionCountsResponse>, | ||
) | ||
|
||
@Serializable | ||
data class PtSessionCountsResponse( | ||
val date: String, | ||
val count: Int, | ||
) | ||
|
||
fun PtSessionCountsResponse.toDomain(dateFormatter: DateFormatter) = | ||
DailyPtSessionCount( | ||
date = dateFormatter.parse(date), | ||
count = count, | ||
) |
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
22 changes: 22 additions & 0 deletions
22
data/network/src/main/java/co/kr/data/network/source/TrainerRemoteDataSource.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,22 @@ | ||
package co.kr.data.network.source | ||
|
||
import co.kr.data.network.model.trainer.MonthlyPtSessionCountsResponse | ||
import co.kr.data.network.service.ApiService | ||
import co.kr.data.network.util.networkHandler | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class TrainerRemoteDataSource @Inject constructor( | ||
private val apiService: ApiService, | ||
) { | ||
suspend fun getMonthlyPtSessionCounts( | ||
year: Int, | ||
month: Int, | ||
): MonthlyPtSessionCountsResponse = networkHandler { | ||
apiService.getMonthlyPtSessionCounts( | ||
year = year, | ||
month = month, | ||
) | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
data/repository/src/main/java/co/kr/data/repository/TrainerRepositoryImpl.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,24 @@ | ||
package co.kr.data.repository | ||
|
||
import co.kr.data.network.model.trainer.toDomain | ||
import co.kr.data.network.source.TrainerRemoteDataSource | ||
import co.kr.tnt.domain.model.trainer.DailyPtSessionCount | ||
import co.kr.tnt.domain.repository.TrainerRepository | ||
import co.kr.tnt.domain.utils.DateFormatter | ||
import java.time.YearMonth | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
internal class TrainerRepositoryImpl @Inject constructor( | ||
private val trainerRemoteDataSource: TrainerRemoteDataSource, | ||
private val dateFormatter: DateFormatter, | ||
) : TrainerRepository { | ||
override suspend fun getMonthlyPtSessionCounts(yearMonth: YearMonth): List<DailyPtSessionCount> = | ||
trainerRemoteDataSource.getMonthlyPtSessionCounts( | ||
year = yearMonth.year, | ||
month = yearMonth.monthValue, | ||
).calendarPtLessonCounts.map { response -> | ||
response.toDomain(dateFormatter) | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
domain/src/main/java/co/kr/tnt/domain/model/trainer/DailyPtSessionCount.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 co.kr.tnt.domain.model.trainer | ||
|
||
import java.time.LocalDate | ||
|
||
data class DailyPtSessionCount( | ||
val date: LocalDate, | ||
val count: Int, | ||
) |
8 changes: 8 additions & 0 deletions
8
domain/src/main/java/co/kr/tnt/domain/repository/TrainerRepository.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 co.kr.tnt.domain.repository | ||
|
||
import co.kr.tnt.domain.model.trainer.DailyPtSessionCount | ||
import java.time.YearMonth | ||
|
||
interface TrainerRepository { | ||
suspend fun getMonthlyPtSessionCounts(yearMonth: YearMonth): List<DailyPtSessionCount> | ||
} |
27 changes: 27 additions & 0 deletions
27
domain/src/main/java/co/kr/tnt/domain/utils/DateFormatter.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 co.kr.tnt.domain.utils | ||
|
||
import java.time.LocalDate | ||
import java.time.format.DateTimeFormatter | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class DateFormatter @Inject constructor() { | ||
fun parse( | ||
rawDate: String, | ||
formatter: DateTimeFormatter = DEFAULT_DATE_FORMAT, | ||
): LocalDate { | ||
require(rawDate.isNotBlank()) | ||
|
||
return LocalDate.parse(rawDate, formatter) | ||
} | ||
|
||
fun format( | ||
date: LocalDate, | ||
formatter: DateTimeFormatter = DEFAULT_DATE_FORMAT, | ||
): String = formatter.format(date) | ||
|
||
companion object { | ||
private val DEFAULT_DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd") | ||
} | ||
} |
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.