File tree Expand file tree Collapse file tree 5 files changed +26
-1
lines changed
data/src/main/java/com/whyranoid/data/account
domain/src/main/java/com/whyranoid/domain Expand file tree Collapse file tree 5 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
1
package com.whyranoid.data.account
2
2
3
+ import com.whyranoid.data.model.RunningHistoryEntity
3
4
import com.whyranoid.domain.model.RunningHistory
4
5
import kotlinx.coroutines.flow.Flow
5
6
6
7
interface RunningHistoryLocalDataSource {
7
8
fun getRunningHistory (): Flow <Result <List <RunningHistory >>>
9
+ suspend fun saveRunningHistory (runningHistoryEntity : RunningHistoryEntity ): Result <RunningHistory >
8
10
}
Original file line number Diff line number Diff line change 1
1
package com.whyranoid.data.account
2
2
3
+ import com.whyranoid.data.model.RunningHistoryEntity
4
+ import com.whyranoid.data.model.toRunningHistory
3
5
import com.whyranoid.domain.model.RunningHistory
4
6
import kotlinx.coroutines.flow.Flow
5
7
import kotlinx.coroutines.flow.map
@@ -18,4 +20,11 @@ class RunningHistoryLocalDataSourceImpl @Inject constructor(
18
20
}
19
21
}
20
22
}
23
+
24
+ override suspend fun saveRunningHistory (runningHistoryEntity : RunningHistoryEntity ): Result <RunningHistory > {
25
+ return kotlin.runCatching {
26
+ runningHistoryDao.addRunningHistory(runningHistoryEntity)
27
+ runningHistoryEntity.toRunningHistory()
28
+ }
29
+ }
21
30
}
Original file line number Diff line number Diff line change 1
1
package com.whyranoid.data.account
2
2
3
+ import com.whyranoid.data.model.RunningHistoryEntity
3
4
import com.whyranoid.domain.model.RunningHistory
4
5
import com.whyranoid.domain.repository.RunningHistoryRepository
5
6
import kotlinx.coroutines.flow.Flow
@@ -17,12 +18,22 @@ class RunningHistoryRepositoryImpl @Inject constructor(
17
18
}
18
19
19
20
override suspend fun saveRunningHistory (
21
+ historyId : String ,
20
22
startedAt : Long ,
21
23
finishedAt : Long ,
22
24
totalRunningTime : Int ,
23
25
pace : Double ,
24
26
totalDistance : Double
25
27
): Result <RunningHistory > {
26
- TODO (" Not yet implemented" )
28
+ return runningHistoryLocalDataSource.saveRunningHistory(
29
+ RunningHistoryEntity (
30
+ historyId = historyId,
31
+ startedAt = startedAt,
32
+ finishedAt = finishedAt,
33
+ totalRunningTime = totalRunningTime,
34
+ pace = pace,
35
+ totalDistance = totalDistance
36
+ )
37
+ )
27
38
}
28
39
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ interface RunningHistoryRepository {
13
13
14
14
// 운동한 기록 저장하기 - 로컬
15
15
suspend fun saveRunningHistory (
16
+ historyId : String ,
16
17
startedAt : Long ,
17
18
finishedAt : Long ,
18
19
totalRunningTime : Int ,
Original file line number Diff line number Diff line change @@ -6,13 +6,15 @@ import javax.inject.Inject
6
6
7
7
class SaveRunningHistoryUseCase @Inject constructor(private val runningHistoryRepository : RunningHistoryRepository ) {
8
8
suspend operator fun invoke (
9
+ historyId : String ,
9
10
startedAt : Long ,
10
11
finishedAt : Long ,
11
12
totalRunningTime : Int ,
12
13
pace : Double ,
13
14
totalDistance : Double
14
15
): Result <RunningHistory > {
15
16
return runningHistoryRepository.saveRunningHistory(
17
+ historyId = historyId,
16
18
startedAt = startedAt,
17
19
finishedAt = finishedAt,
18
20
totalRunningTime = totalRunningTime,
You can’t perform that action at this time.
0 commit comments