Skip to content

Commit

Permalink
Merge pull request #123 from GSM-MSG/feature/#122_set_up_get_detail_club
Browse files Browse the repository at this point in the history
🔀 :: (#122) Set Up Get Detail Club
  • Loading branch information
Chaejongin12 authored Dec 5, 2023
2 parents ef85513 + ff65cc9 commit dab2b9c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,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 kotlinx.coroutines.flow.Flow

interface ClubRepository {
suspend fun getClubList(highSchool: HighSchool): Flow<List<ClubListResponse>>
suspend fun getClubDetail(id: Long): Flow<ClubDetailResponse>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,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.network.datasource.club.ClubDataSource
import kotlinx.coroutines.flow.Flow
Expand All @@ -13,4 +14,8 @@ class ClubRepositoryImpl @Inject constructor(
return clubDataSource.getClubList(highSchool = highSchool)
}

override suspend fun getClubDetail(id: Long): Flow<ClubDetailResponse> {
return clubDataSource.getClubDetail(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 GetClubDetailUseCase @Inject constructor(
private val clubRepository: ClubRepository
) {
suspend operator fun invoke(id: Long) = runCatching {
clubRepository.getClubDetail(id = id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.msg.model.remote.response.club

data class ClubDetailResponse(
val clubName: String,
val highSchoolName: String,
val studentHeadCount: Int,
)
7 changes: 7 additions & 0 deletions core/network/src/main/java/com/msg/network/api/ClubAPI.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
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 retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

interface ClubAPI {
@GET("club")
suspend fun getClubList(
@Query("highschool") highSchool: HighSchool,
): List<ClubListResponse>

@GET("club/{id}")
suspend fun getClubDetail(
@Path("id") id: Long,
): ClubDetailResponse
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,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 kotlinx.coroutines.flow.Flow

interface ClubDataSource {
suspend fun getClubList(highSchool: HighSchool): Flow<List<ClubListResponse>>
suspend fun getClubDetail(id: Long): Flow<ClubDetailResponse>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,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.network.api.ClubAPI
import com.msg.network.util.BitgoeulApiHandler
Expand All @@ -18,4 +19,12 @@ class ClubDataSourceImpl @Inject constructor(
.sendRequest()
)
}

override suspend fun getClubDetail(id: Long): Flow<ClubDetailResponse> = flow {
emit(
BitgoeulApiHandler<ClubDetailResponse>()
.httpRequest { clubAPI.getClubDetail(id = id) }
.sendRequest()
)
}
}

0 comments on commit dab2b9c

Please sign in to comment.