Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: (#124) Set Up Get Student Belong Club List #131

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package com.msg.data.repository.club
import com.msg.model.remote.enumdatatype.HighSchool
import com.msg.model.remote.response.club.ClubDetailResponse
import com.msg.model.remote.response.club.ClubListResponse
import com.msg.model.remote.response.club.StudentBelongClubResponse
import kotlinx.coroutines.flow.Flow

interface ClubRepository {
suspend fun getClubList(highSchool: HighSchool): Flow<List<ClubListResponse>>
suspend fun getClubDetail(id: Long): Flow<ClubDetailResponse>
suspend fun getStudentBelongClubList(id: Long): Flow<List<StudentBelongClubResponse>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.msg.data.repository.club
import com.msg.model.remote.enumdatatype.HighSchool
import com.msg.model.remote.response.club.ClubDetailResponse
import com.msg.model.remote.response.club.ClubListResponse
import com.msg.model.remote.response.club.StudentBelongClubResponse
import com.msg.network.datasource.club.ClubDataSource
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
Expand All @@ -18,4 +19,8 @@ class ClubRepositoryImpl @Inject constructor(
return clubDataSource.getClubDetail(id = id)
}

override suspend fun getStudentBelongClubList(id: Long): Flow<List<StudentBelongClubResponse>> {
return clubDataSource.getStudentBelongClubList(id = id)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.domain.club

import com.msg.data.repository.club.ClubRepository
import javax.inject.Inject

class GetStudentBelongClubUseCase @Inject constructor(
private val clubRepository: ClubRepository
) {
suspend operator fun invoke(id: Long) = runCatching {
clubRepository.getStudentBelongClubList(id = id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.msg.model.remote.response.club

import com.msg.model.remote.enumdatatype.Authority
import java.util.UUID

data class StudentBelongClubResponse(
val id: UUID,
val name: String,
val authority: Authority,
)
6 changes: 6 additions & 0 deletions core/network/src/main/java/com/msg/network/api/ClubAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.msg.network.api
import com.msg.model.remote.enumdatatype.HighSchool
import com.msg.model.remote.response.club.ClubDetailResponse
import com.msg.model.remote.response.club.ClubListResponse
import com.msg.model.remote.response.club.StudentBelongClubResponse
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query
Expand All @@ -17,4 +18,9 @@ interface ClubAPI {
suspend fun getClubDetail(
@Path("id") id: Long,
): ClubDetailResponse

@GET("club/{id}/member")
suspend fun getStudentBelongClubList(
@Path("id") id: Long,
): List<StudentBelongClubResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package com.msg.network.datasource.club
import com.msg.model.remote.enumdatatype.HighSchool
import com.msg.model.remote.response.club.ClubDetailResponse
import com.msg.model.remote.response.club.ClubListResponse
import com.msg.model.remote.response.club.StudentBelongClubResponse
import kotlinx.coroutines.flow.Flow

interface ClubDataSource {
suspend fun getClubList(highSchool: HighSchool): Flow<List<ClubListResponse>>
suspend fun getClubDetail(id: Long): Flow<ClubDetailResponse>
suspend fun getStudentBelongClubList(id:Long): Flow<List<StudentBelongClubResponse>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.msg.network.datasource.club
import com.msg.model.remote.enumdatatype.HighSchool
import com.msg.model.remote.response.club.ClubDetailResponse
import com.msg.model.remote.response.club.ClubListResponse
import com.msg.model.remote.response.club.StudentBelongClubResponse
import com.msg.network.api.ClubAPI
import com.msg.network.util.BitgoeulApiHandler
import kotlinx.coroutines.flow.Flow
Expand All @@ -27,4 +28,12 @@ class ClubDataSourceImpl @Inject constructor(
.sendRequest()
)
}

override suspend fun getStudentBelongClubList(id: Long): Flow<List<StudentBelongClubResponse>> = flow {
emit(
BitgoeulApiHandler<List<StudentBelongClubResponse>>()
.httpRequest { clubAPI.getStudentBelongClubList(id = id) }
.sendRequest()
)
}
}
Loading