-
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 #346 from 6QuizOnTheBlock/and/feat#323-group-sse
And/feat#323 group sse
- Loading branch information
Showing
46 changed files
with
1,035 additions
and
153 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
6 changes: 6 additions & 0 deletions
6
android/core/model/src/main/java/com/sixkids/model/MatchingRoom.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,6 @@ | ||
package com.sixkids.model | ||
|
||
data class MatchingRoom( | ||
val dataKey: String, | ||
val minCount: Int | ||
) |
12 changes: 12 additions & 0 deletions
12
android/core/model/src/main/java/com/sixkids/model/RunningChallengeByStudent.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.sixkids.model | ||
|
||
import java.time.LocalDateTime | ||
|
||
data class RunningChallengeByStudent( | ||
val challenge: Challenge, | ||
val leaderStatus: Boolean? = null, | ||
val memberNames: List<MemberSimple>, | ||
val type: GroupType, | ||
val createTime: LocalDateTime?, | ||
val endStatus: Boolean? | ||
) |
16 changes: 16 additions & 0 deletions
16
android/core/model/src/main/java/com/sixkids/model/SSeData.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,16 @@ | ||
package com.sixkids.model | ||
|
||
import kotlinx.datetime.toKotlinLocalDateTime | ||
import kotlinx.serialization.Serializable | ||
import java.time.LocalDateTime | ||
import kotlinx.datetime.LocalDateTime as KotlinLocalDateTime | ||
|
||
@Serializable | ||
data class SseData( | ||
val eventType: String, | ||
val receiverId: Long, | ||
val url: Long?, | ||
val data: String?, | ||
val time: KotlinLocalDateTime = LocalDateTime.now().toKotlinLocalDateTime() | ||
|
||
) |
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
39 changes: 39 additions & 0 deletions
39
android/data/src/main/java/com/sixkids/data/api/GroupService.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,39 @@ | ||
package com.sixkids.data.api | ||
|
||
import com.sixkids.data.model.response.GroupMatchingRoomResponse | ||
import com.sixkids.data.network.ApiResponse | ||
import com.sixkids.data.network.ApiResult | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Query | ||
|
||
interface GroupService { | ||
@POST("challenges/groups/matchingroom") | ||
suspend fun createMatchingRoom( | ||
@Query("challengeId") challengeId: Long, | ||
): ApiResult<ApiResponse<GroupMatchingRoomResponse>> | ||
|
||
@GET("challenges/groups/invite") | ||
suspend fun inviteFriend( | ||
@Query("key") key: String, | ||
@Query("memberId") memberId: Long, | ||
): ApiResult<ApiResponse<Unit>> | ||
|
||
@DELETE("challenges/groups/matching") | ||
suspend fun deportFriend( | ||
@Query("key") key: String, | ||
@Query("memberId") memberId: Long, | ||
): ApiResult<ApiResponse<Unit>> | ||
|
||
@POST("challenges/groups/join") | ||
suspend fun joinGroup( | ||
@Query("key") key: String, | ||
@Query("joinStatus") joinStatus : Boolean, | ||
): ApiResult<ApiResponse<Unit>> | ||
|
||
@POST("challenges/groups") | ||
suspend fun createGroup( | ||
@Query("key") key: String, | ||
): ApiResult<ApiResponse<Long>> | ||
} |
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
14 changes: 14 additions & 0 deletions
14
android/data/src/main/java/com/sixkids/data/model/response/GroupMatchingRoomResponse.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,14 @@ | ||
package com.sixkids.data.model.response | ||
|
||
import com.sixkids.model.MatchingRoom | ||
|
||
data class GroupMatchingRoomResponse( | ||
val dataKey: String, | ||
val minCount: Int | ||
) | ||
|
||
internal fun GroupMatchingRoomResponse.toModel(): MatchingRoom = | ||
MatchingRoom( | ||
dataKey = dataKey, | ||
minCount = minCount | ||
) |
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
26 changes: 26 additions & 0 deletions
26
...d/data/src/main/java/com/sixkids/data/model/response/RunningChallengeByStudentResponse.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,26 @@ | ||
package com.sixkids.data.model.response | ||
|
||
import com.sixkids.model.GroupType | ||
import com.sixkids.model.RunningChallengeByStudent | ||
import com.squareup.moshi.Json | ||
import java.time.LocalDateTime | ||
|
||
data class RunningChallengeByStudentResponse( | ||
@Json(name = "challengeSimpleDTO") | ||
val challenge: ChallengeResponse, | ||
val leaderStatus: Boolean?, | ||
@Json(name = "memberList") | ||
val memberNames: List<MemberSimpleResponse>?, | ||
val type: String, | ||
val createTime: LocalDateTime?, | ||
val endStatus: Boolean? | ||
) | ||
|
||
internal fun RunningChallengeByStudentResponse.toModel() = RunningChallengeByStudent( | ||
challenge = challenge.toModel(), | ||
leaderStatus = leaderStatus, | ||
memberNames = memberNames?.map { it.toModel() }?: emptyList(), | ||
type = GroupType.valueOf(type), | ||
createTime = createTime, | ||
endStatus = endStatus | ||
) |
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
25 changes: 25 additions & 0 deletions
25
android/data/src/main/java/com/sixkids/data/repository/group/GroupRepositoryImpl.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,25 @@ | ||
package com.sixkids.data.repository.group | ||
|
||
import com.sixkids.data.model.response.toModel | ||
import com.sixkids.data.repository.group.remote.GroupDataSource | ||
import com.sixkids.domain.repository.GroupRepository | ||
import com.sixkids.model.MatchingRoom | ||
import javax.inject.Inject | ||
|
||
class GroupRepositoryImpl @Inject constructor( | ||
private val groupDataSource: GroupDataSource | ||
) : GroupRepository { | ||
override suspend fun createMatchingRoom(challengeId: Long): MatchingRoom = | ||
groupDataSource.createMatchingRoom(challengeId).toModel() | ||
|
||
override suspend fun inviteFriend(key: String, memberId: Long) = | ||
groupDataSource.inviteFriend(key, memberId) | ||
|
||
override suspend fun deportFriend(key: String, memberId: Long) = | ||
groupDataSource.deportFriend(key, memberId) | ||
|
||
override suspend fun joinGroup(key: String, joinStatus: Boolean) = | ||
groupDataSource.joinGroup(key, joinStatus) | ||
|
||
override suspend fun createGroup(key: String): Long = groupDataSource.createGroup(key) | ||
} |
15 changes: 15 additions & 0 deletions
15
android/data/src/main/java/com/sixkids/data/repository/group/remote/GroupDataSource.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.sixkids.data.repository.group.remote | ||
|
||
import com.sixkids.data.model.response.GroupMatchingRoomResponse | ||
|
||
interface GroupDataSource { | ||
suspend fun createMatchingRoom(challengeId: Long): GroupMatchingRoomResponse | ||
|
||
suspend fun inviteFriend(key: String, memberId: Long) | ||
|
||
suspend fun deportFriend(key: String, memberId: Long) | ||
|
||
suspend fun joinGroup(key: String, joinStatus: Boolean) | ||
|
||
suspend fun createGroup(key: String): Long | ||
} |
24 changes: 24 additions & 0 deletions
24
android/data/src/main/java/com/sixkids/data/repository/group/remote/GroupDataSourceImpl.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 com.sixkids.data.repository.group.remote | ||
|
||
import com.sixkids.data.api.GroupService | ||
import com.sixkids.data.model.response.GroupMatchingRoomResponse | ||
import javax.inject.Inject | ||
|
||
class GroupDataSourceImpl @Inject constructor( | ||
private val groupService: GroupService | ||
) : GroupDataSource { | ||
override suspend fun createMatchingRoom(challengeId: Long): GroupMatchingRoomResponse = | ||
groupService.createMatchingRoom(challengeId).getOrThrow().data | ||
|
||
override suspend fun inviteFriend(key: String, memberId: Long) = | ||
groupService.inviteFriend(key, memberId).getOrThrow().data | ||
|
||
override suspend fun deportFriend(key: String, memberId: Long) = | ||
groupService.deportFriend(key, memberId).getOrThrow().data | ||
|
||
override suspend fun joinGroup(key: String, joinStatus: Boolean) = | ||
groupService.joinGroup(key, joinStatus).getOrThrow().data | ||
|
||
override suspend fun createGroup(key: String): Long = | ||
groupService.createGroup(key).getOrThrow().data | ||
} |
Oops, something went wrong.