-
Notifications
You must be signed in to change notification settings - Fork 1
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 #92 from Team-Walkie/refactor/challenge_model
챌린지 응답 모델 변경, 챌린지 완료 Api 연동
- Loading branch information
Showing
14 changed files
with
153 additions
and
93 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
45 changes: 27 additions & 18 deletions
45
data/src/main/java/com/whyranoid/data/model/challenge/ChallengeDetailResponse.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 |
---|---|---|
@@ -1,29 +1,38 @@ | ||
package com.whyranoid.data.model.challenge | ||
|
||
import com.whyranoid.domain.model.challenge.Challenge | ||
import com.whyranoid.domain.model.challenge.ChallengeType | ||
import com.whyranoid.domain.util.EMPTY | ||
|
||
data class ChallengeDetailResponse( | ||
val challenge: ChallengeFromServer, | ||
val walkies: List<Walkie> | ||
) { | ||
fun toChallenge(): com.whyranoid.domain.model.challenge.Challenge { | ||
val participants = walkies.map { it.toUser() } | ||
return com.whyranoid.domain.model.challenge.Challenge( | ||
badge = challenge.badge.toBadge(), | ||
calorie = challenge.calorie, | ||
challengeType = ChallengeType.getChallengeTypeByString(challenge.category), | ||
id = challenge.challengeId.toLong(), | ||
contents = challenge.content, | ||
imageUrl = challenge.img, | ||
title = challenge.name, | ||
process = challenge.progress, | ||
participants = participants, | ||
participantCount = participants.size, | ||
period = challenge.period, | ||
distance = challenge.distance, | ||
endTime = challenge.endTime, | ||
startTime = challenge.startTime, | ||
status = challenge.status | ||
fun toChallenge(): Challenge { | ||
val challenge = Challenge( | ||
challenge.accCalories, | ||
challenge.accCount, | ||
challenge.accDistance, | ||
challenge.accTime, | ||
challenge.badge.toBadge(), | ||
challenge.calorie, | ||
ChallengeType.getChallengeTypeByString(challenge.category ?: String.EMPTY), | ||
challenge.challengeEdate, | ||
challenge.challengeId, | ||
challenge.challengeSdate, | ||
challenge.content, | ||
challenge.distance, | ||
challenge.endTime, | ||
challenge.goalCount, | ||
challenge.img, | ||
challenge.name, | ||
challenge.period, | ||
challenge.progress, | ||
challenge.startTime, | ||
challenge.status, | ||
challenge.timeLimit, | ||
walkies.map { it.toUser() } | ||
) | ||
return challenge | ||
} | ||
} |
20 changes: 14 additions & 6 deletions
20
data/src/main/java/com/whyranoid/data/model/challenge/ChallengeFromServer.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 |
---|---|---|
@@ -1,17 +1,25 @@ | ||
package com.whyranoid.data.model.challenge | ||
|
||
data class ChallengeFromServer( | ||
val accCalories: Double?, | ||
val accCount: Int?, | ||
val accDistance: Double?, | ||
val accTime: String? = null, | ||
val badge: BadgeResponse, | ||
val calorie: Int?, | ||
val category: String, | ||
val calorie: Int, | ||
val category: String?, | ||
val challengeEdate: String? = null, | ||
val challengeId: Int, | ||
val challengeSdate: String? = null, | ||
val content: String, | ||
val distance: Int?, | ||
val endTime: String, | ||
val endTime: String?, | ||
val goalCount: Int?, | ||
val img: String, | ||
val name: String, | ||
val period: Int?, | ||
val progress: Int, | ||
val startTime: String, | ||
val status: String | ||
val progress: Int?, | ||
val startTime: String?, | ||
val status: String?, | ||
val timeLimit: Int? | ||
) |
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
15 changes: 15 additions & 0 deletions
15
domain/src/main/java/com/whyranoid/domain/usecase/CompleteChallengeUseCase.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.whyranoid.domain.usecase | ||
|
||
import com.whyranoid.domain.repository.ChallengeRepository | ||
import javax.inject.Inject | ||
|
||
class CompleteChallengeUseCase @Inject constructor( | ||
private val challengeRepository: ChallengeRepository, | ||
private val getMyUidUseCase: GetMyUidUseCase | ||
) { | ||
suspend operator fun invoke(challengeId: Int): Result<Unit> { | ||
val myId = getMyUidUseCase() | ||
return challengeRepository.changeChallengeStatus(challengeId,"C", myId.getOrNull()?.toInt() ?: -1) | ||
} | ||
|
||
} |
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
Oops, something went wrong.