-
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.
- Loading branch information
Showing
6 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/example/howdroid/data/datasource/remote/ChartDataSource.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.example.howdroid.data.datasource.remote | ||
|
||
import com.example.howdroid.data.model.response.ResponseStatistic | ||
import com.example.howdroid.data.service.ChartService | ||
import javax.inject.Inject | ||
|
||
class ChartDataSource @Inject constructor( | ||
private val chartService: ChartService | ||
) { | ||
suspend fun fetchStatistic(selectedDate: String): ResponseStatistic = | ||
chartService.fetchStatistic(selectedDate) | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/example/howdroid/data/model/response/ResponseStatistic.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,28 @@ | ||
package com.example.howdroid.data.model.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseStatistic( | ||
val nowBestCategory: String, | ||
val nowCategoryDate: List<NowCategoryDate>, | ||
val nowFailtagList: List<NowFailtag>, | ||
val nowTodoCnt: Int, | ||
val nowTodoDoneCnt: Int, | ||
val nowWorstFailtag: String, | ||
val prevTodoCnt: Int, | ||
val prevTodoDoneCnt: Int, | ||
val rateOfChange: Int, | ||
val selectedDate: String | ||
) { | ||
@Serializable | ||
data class NowCategoryDate( | ||
val nowCategory: String, | ||
val nowCategoryRate: Int | ||
) | ||
@Serializable | ||
data class NowFailtag( | ||
val nowFailtag: String, | ||
val nowFailtagRate: Int | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/example/howdroid/data/repository/ChartRepositoryImpl.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,15 @@ | ||
package com.example.howdroid.data.repository | ||
|
||
import com.example.howdroid.data.datasource.remote.ChartDataSource | ||
import com.example.howdroid.data.model.response.ResponseStatistic | ||
import com.example.howdroid.domain.repository.ChartRepository | ||
import javax.inject.Inject | ||
|
||
class ChartRepositoryImpl @Inject constructor( | ||
private val chartDataSource: ChartDataSource | ||
) : ChartRepository { | ||
override suspend fun fetchStatistic(selectedDate: String): Result<ResponseStatistic> = | ||
runCatching { | ||
chartDataSource.fetchStatistic(selectedDate) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/example/howdroid/data/service/ChartService.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.example.howdroid.data.service | ||
|
||
import com.example.howdroid.data.model.response.ResponseStatistic | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
interface ChartService { | ||
@GET("statistic/{selectedDate}") | ||
suspend fun fetchStatistic( | ||
@Path("selectedDate") selectedDate: String, | ||
): ResponseStatistic | ||
} |
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
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/example/howdroid/domain/repository/ChartRepository.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,7 @@ | ||
package com.example.howdroid.domain.repository | ||
|
||
import com.example.howdroid.data.model.response.ResponseStatistic | ||
|
||
interface ChartRepository { | ||
suspend fun fetchStatistic(selectedDate: String): Result<ResponseStatistic> | ||
} |