-
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 #183 from MaeumGaGym/BAC-519-와카타임_시간_조회_API
PR :: 와카타임 총 시간(s) 조회 API
- Loading branch information
Showing
4 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...mgagym-core/src/main/kotlin/com/info/maeumgagym/wakatime/dto/response/WakatimeResponse.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.info.maeumgagym.wakatime.dto.response | ||
|
||
data class WakatimeResponse( | ||
val totalSeconds: Long | ||
) |
10 changes: 10 additions & 0 deletions
10
maeumgagym-core/src/main/kotlin/com/info/maeumgagym/wakatime/port/in/ReadWakaTimeUseCase.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,10 @@ | ||
package com.info.maeumgagym.wakatime.port.`in` | ||
|
||
import com.info.maeumgagym.wakatime.dto.response.WakatimeResponse | ||
|
||
interface ReadWakaTimeUseCase { | ||
|
||
fun readTotalSeconds(): WakatimeResponse | ||
|
||
fun readDailySeconds(): WakatimeResponse | ||
} |
27 changes: 27 additions & 0 deletions
27
maeumgagym-core/src/main/kotlin/com/info/maeumgagym/wakatime/service/ReadWakatimeService.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.info.maeumgagym.wakatime.service | ||
|
||
import com.info.common.ReadOnlyUseCase | ||
import com.info.maeumgagym.auth.port.out.ReadCurrentUserPort | ||
import com.info.maeumgagym.wakatime.dto.response.WakatimeResponse | ||
import com.info.maeumgagym.wakatime.port.`in`.ReadWakaTimeUseCase | ||
import com.info.maeumgagym.wakatime.port.out.ReadWakaTimePort | ||
import java.time.LocalDate | ||
|
||
@ReadOnlyUseCase | ||
internal class ReadWakatimeService( | ||
private val readCurrentUserPort: ReadCurrentUserPort, | ||
private val readWakaTimePort: ReadWakaTimePort | ||
) : ReadWakaTimeUseCase { | ||
|
||
override fun readTotalSeconds(): WakatimeResponse = | ||
WakatimeResponse(readCurrentUserPort.readCurrentUser().totalWakaTime) | ||
|
||
override fun readDailySeconds(): WakatimeResponse { | ||
val user = readCurrentUserPort.readCurrentUser() | ||
|
||
return readWakaTimePort.readByUserIdAndDate(user.id!!, LocalDate.now()) | ||
?.run { | ||
WakatimeResponse(waka) | ||
} ?: WakatimeResponse(0) | ||
} | ||
} |
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