Skip to content

Commit

Permalink
Merge pull request #357 from 6QuizOnTheBlock/and/feat#348-student_man…
Browse files Browse the repository at this point in the history
…age_detail

And/feat#348 student manage detail
  • Loading branch information
ghddbwns9808 authored May 18, 2024
2 parents ddf53f0 + 690119f commit a11c095
Show file tree
Hide file tree
Showing 23 changed files with 759 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ import com.sixkids.designsystem.theme.UlbanTypography
@Composable
fun StudentSimpleCardItem(
modifier: Modifier = Modifier,
id: Long = 0,
name: String = "",
photo: String = "",
score: Int? = null,
onClick: () -> Unit = {}
onClick: (Long) -> Unit = {}
) {
Card(
modifier = modifier,
Expand All @@ -44,7 +45,7 @@ fun StudentSimpleCardItem(
defaultElevation = 4.dp,
pressedElevation = 8.dp
),
onClick = onClick
onClick = {onClick(id)}
) {
Column(
modifier = Modifier
Expand Down
12 changes: 12 additions & 0 deletions android/core/model/src/main/java/com/sixkids/model/MemberDetail.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sixkids.model

data class MemberDetail(
val name: String = "",
val photo: String = "",
val isolationPoint: Double = 0.0,
// val isolationPoint: Int = -1,
val exp: Int = -1,
val challengeCount: Int = -1,
val relayCount: Int = -1,
val postCount: Int = -1,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.sixkids.model

data class StudentRelation(
val id: Long = -1,
val name: String = "",
val relationPoint: Int = 0,
val tagGreetingCount: Int = 0,
val groupCount: Int = 0,
val receiveCount: Int = 0,
val sendCount: Int = 0,
)
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
package com.sixkids.data.api

import com.sixkids.data.model.response.StudentDetailResponse
import com.sixkids.data.model.response.StudentHomeResponse
import com.sixkids.data.model.response.StudentRelationDetailResponse
import com.sixkids.data.model.response.StudentWithRelationScoreResponse
import com.sixkids.data.network.ApiResponse
import com.sixkids.data.network.ApiResult
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

interface MemberOrgService {
@GET("organizations/{id}/home")
suspend fun getStudentHomeInfo(
@Path("id") organizationId: Long
): ApiResult<ApiResponse<StudentHomeResponse>>

@GET("organizations/{id}")
suspend fun getMemberDetail(
@Path("id") organizationId: Long,
@Query("memberId") memberId: Long
): ApiResult<ApiResponse<StudentDetailResponse>>

@GET("organizations/{id}/relations")
suspend fun getRelationSimple(
@Path("id") organizationId: Long,
@Query("memberId") memberId: Int,
@Query("limit") relationType: Int? = null
): ApiResult<ApiResponse<List<StudentWithRelationScoreResponse>>>

@GET("organizations/{id}/relation")
suspend fun getRelationDetail(
@Path("id") organizationId: Long,
@Query("sourceMemberId") sourceMemberId: Int,
@Query("targetMemberId") targetMemberId: Int
): ApiResult<ApiResponse<StudentRelationDetailResponse>>


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.sixkids.data.model.response

import com.sixkids.model.MemberDetail

data class StudentDetailResponse(
val name: String = "",
val photo: String = "",
//todo 등수로 바꾸기
val isolationPoint: Double = 0.0,
val exp: Int = -1,
val challengeCount: Int = -1,
val relayCount: Int = -1,
val postCount: Int = -1,
)

internal fun StudentDetailResponse.toModel(): MemberDetail {
return MemberDetail(
name = this.name,
photo = this.photo,
isolationPoint = this.isolationPoint,
exp = this.exp,
challengeCount = this.challengeCount,
relayCount = this.relayCount,
postCount = this.postCount,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.sixkids.data.model.response

import com.sixkids.model.StudentRelation

data class StudentRelationDetailResponse(
val memberId: Long = -1,
val memberName: String = "",
val relationPoint: Int = 0,
val tagGreetingCount: Int = 0,
val groupCount: Int = 0,
val receiveCount: Int = 0,
val sendCount: Int = 0,
)

internal fun StudentRelationDetailResponse.toModel() = StudentRelation(
id = memberId,
name = memberName,
relationPoint = relationPoint,
tagGreetingCount = tagGreetingCount,
groupCount = groupCount,
receiveCount = receiveCount,
sendCount = sendCount,
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import com.sixkids.data.model.response.toModel
import com.sixkids.data.repository.organization.local.OrganizationLocalDataSource
import com.sixkids.data.repository.organization.remote.OrganizationRemoteDataSource
import com.sixkids.domain.repository.OrganizationRepository
import com.sixkids.model.MemberDetail
import com.sixkids.model.ClassSummary
import com.sixkids.model.MemberSimple
import com.sixkids.model.MemberSimpleWithScore
import com.sixkids.model.Organization
import com.sixkids.model.StudentRelation
import javax.inject.Inject

class OrganizationRepositoryImpl @Inject constructor(
Expand Down Expand Up @@ -58,8 +61,28 @@ class OrganizationRepositoryImpl @Inject constructor(
override suspend fun loadSelectedOrganizationName(): String {
return organizationLocalDataSource.getSelectedOrganizationName()
}

override suspend fun getOrganizationMembers(orgId: Int): List<MemberSimple> {
return organizationRemoteDataSource.getOrganizationMembers(orgId)
}

override suspend fun getStudentDetail(orgId: Long, studentId: Long): MemberDetail {
return organizationRemoteDataSource.getStudentDetail(orgId, studentId)
}

override suspend fun getStudentRelation(
orgId: Long,
studentId: Long,
limit: Int?
): List<MemberSimpleWithScore> {
return organizationRemoteDataSource.getStudentRelation(orgId, studentId, limit)
}

override suspend fun getStudentRelationDetail(
orgId: Long,
sourceStudentId: Long,
targetStudentId: Long
): StudentRelation {
return organizationRemoteDataSource.getStudentRelationDetail(orgId, sourceStudentId, targetStudentId)
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.sixkids.data.repository.organization.remote

import com.sixkids.data.model.response.ApiResponse
import com.sixkids.data.model.response.ClassSummaryResponse
import com.sixkids.data.network.ApiResult
import com.sixkids.model.MemberDetail
import com.sixkids.model.MemberSimple
import com.sixkids.model.MemberSimpleWithScore
import com.sixkids.model.Organization
import retrofit2.http.Path
import com.sixkids.model.StudentRelation

interface OrganizationRemoteDataSource {
suspend fun getClassList(): List<Organization>
Expand All @@ -19,6 +19,12 @@ interface OrganizationRemoteDataSource {
suspend fun updateOrganization(organizationId: Int, name: String): String

suspend fun getOrganizationInviteCode(organizationId: Int): String

suspend fun getOrganizationMembers(orgId: Int): List<MemberSimple>

suspend fun getStudentDetail(orgId: Long, studentId: Long): MemberDetail

suspend fun getStudentRelation(orgId: Long, studentId: Long, limit: Int?): List<MemberSimpleWithScore>

suspend fun getStudentRelationDetail(orgId: Long, sourceStudentId: Long, targetStudentId: Long): StudentRelation
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package com.sixkids.data.repository.organization.remote

import com.sixkids.data.api.MemberOrgService
import com.sixkids.data.api.OrganizationService
import com.sixkids.data.model.request.JoinOrganizationRequest
import com.sixkids.data.model.request.NewOrganizationRequest
import com.sixkids.data.model.response.ClassSummaryResponse
import com.sixkids.data.model.response.toModel
import com.sixkids.model.MemberDetail
import com.sixkids.model.MemberSimple
import com.sixkids.model.MemberSimpleWithScore
import com.sixkids.model.Organization
import com.sixkids.model.StudentRelation
import javax.inject.Inject

class OrganizationRemoteDataSourceImpl @Inject constructor(
private val organizationService: OrganizationService
private val organizationService: OrganizationService,
private val memberOrgService: MemberOrgService
) : OrganizationRemoteDataSource {
override suspend fun getClassList(): List<Organization> {
return organizationService.getOrganizationList().getOrThrow().data.map { it.toModel() }
Expand Down Expand Up @@ -41,4 +46,24 @@ class OrganizationRemoteDataSourceImpl @Inject constructor(
override suspend fun getOrganizationMembers(orgId: Int): List<MemberSimple> {
return organizationService.getOrganizationMembers(orgId).getOrThrow().data.map { it.toModel() }
}

override suspend fun getStudentDetail(orgId: Long, studentId: Long): MemberDetail {
return memberOrgService.getMemberDetail(orgId, studentId).getOrThrow().data.toModel()
}

override suspend fun getStudentRelation(
orgId: Long,
studentId: Long,
limit: Int?
): List<MemberSimpleWithScore> {
return memberOrgService.getRelationSimple(orgId, studentId.toInt(), limit).getOrThrow().data.map { it.toModel() }
}

override suspend fun getStudentRelationDetail(
orgId: Long,
sourceStudentId: Long,
targetStudentId: Long
): StudentRelation {
return memberOrgService.getRelationDetail(orgId, sourceStudentId.toInt(), targetStudentId.toInt()).getOrThrow().data.toModel()
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.sixkids.domain.repository

import com.sixkids.model.MemberDetail
import com.sixkids.model.ClassSummary
import com.sixkids.model.MemberSimple
import com.sixkids.model.MemberSimpleWithScore
import com.sixkids.model.Organization
import com.sixkids.model.StudentRelation

interface OrganizationRepository {
suspend fun getClassList(): List<Organization>
Expand All @@ -23,6 +26,12 @@ interface OrganizationRepository {
suspend fun saveSelectedOrganizationName(organizationName: String)

suspend fun loadSelectedOrganizationName(): String

suspend fun getOrganizationMembers(orgId: Int): List<MemberSimple>

suspend fun getStudentDetail(orgId: Long, studentId: Long): MemberDetail

suspend fun getStudentRelation(orgId: Long, studentId: Long, limit: Int?): List<MemberSimpleWithScore>

suspend fun getStudentRelationDetail(orgId: Long, sourceStudentId: Long, targetStudentId: Long): StudentRelation
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sixkids.domain.usecase.organization

import com.sixkids.domain.repository.OrganizationRepository
import javax.inject.Inject

class GetMemberRelationUseCase @Inject constructor(
private val organizationRepository: OrganizationRepository
){
suspend operator fun invoke(orgId: Long, studentId: Long, limit: Int?) = runCatching {
organizationRepository.getStudentRelation(orgId, studentId, limit)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.sixkids.domain.usecase.organization

import com.sixkids.domain.repository.OrganizationRepository
import javax.inject.Inject

class GetStudentDetailUseCase @Inject constructor(
private val organizationRepository: OrganizationRepository
) {
suspend operator fun invoke(orgId: Long, studentId: Long) = runCatching {
organizationRepository.getStudentDetail(orgId, studentId)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sixkids.domain.usecase.organization

import com.sixkids.domain.repository.OrganizationRepository
import javax.inject.Inject

class GetStudentRelationUseCase @Inject constructor(
private val organizationRepository: OrganizationRepository
){
suspend operator fun invoke(orgId: Long, sourceMemberId: Long, targetMemberId: Long) = runCatching {
organizationRepository.getStudentRelationDetail(orgId, sourceMemberId, targetMemberId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum class MainNavigationTab(
route = HomeRoute.defaultRoute,
),
BOARD(
iconId = R.drawable.board,
iconId = R.drawable.ic_board,
iconTint = Blue,
labelId = R.string.bottom_navigation_tab_label_board,
route = BoardRoute.defaultRoute,
Expand All @@ -55,7 +55,7 @@ enum class MainNavigationTab(
route = StudentHomeRoute.defaultRoute,
),
STUDENT_BOARD(
iconId = R.drawable.board,
iconId = R.drawable.ic_board,
iconTint = Blue,
labelId = R.string.bottom_navigation_tab_label_board,
route = StudentBoardRoute.defaultRoute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ fun MainScreen(
manageStudentNavGraph(
padding = innerPadding,
navigateToStudentDetail = navigator::navigateManageStudentDetail,
handleException = viewModel::handleException,
)

signInNavGraph(
Expand Down
1 change: 1 addition & 0 deletions android/feature/teacher/managestudent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ android {

dependencies {
implementation(projects.core.designsystem)
implementation(libs.accompanist.pager)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.sixkids.teacher.managestudent.detail

import com.sixkids.model.MemberDetail
import com.sixkids.model.MemberSimpleWithScore
import com.sixkids.model.StudentRelation
import com.sixkids.ui.base.SideEffect
import com.sixkids.ui.base.UiState

data class ManageStudentDetailState(
val memberDetail: MemberDetail = MemberDetail(),
val studentList: List<MemberSimpleWithScore> = emptyList(),
val relation: StudentRelation = StudentRelation(),
val isDialogShowing: Boolean = false,
): UiState

sealed interface ManageStudentDetailEffect : SideEffect{
data class NavigateToChallenge(val studentId: Long) : ManageStudentDetailEffect
data class NavigateToRelay(val studentId: Long) : ManageStudentDetailEffect
data class NavigateToPost(val studentId: Long) : ManageStudentDetailEffect
data class HandleException(val throwable: Throwable, val retry: () -> Unit) : ManageStudentDetailEffect
}
Loading

0 comments on commit a11c095

Please sign in to comment.