diff --git a/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsDataSource.kt b/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsDataSource.kt index cedf44d9..ca44cb42 100644 --- a/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsDataSource.kt +++ b/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsDataSource.kt @@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.Flow interface CommentsDataSource { - suspend fun getCommentsByMedicineId(medicineId: Long): Result + suspend fun getCommentsByMedicineId(medicineId: Long, page: Int, rows: Int, userId: String = "-1"): Result suspend fun getMyCommentsList(): Flow> diff --git a/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsDataSourceImpl.kt b/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsDataSourceImpl.kt index 6eb46afa..d09749bc 100644 --- a/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsDataSourceImpl.kt +++ b/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsDataSourceImpl.kt @@ -18,8 +18,8 @@ class CommentsDataSourceImpl @Inject constructor( private val awsNetworkApi: AwsNetworkApi, ) : CommentsDataSource { - override suspend fun getCommentsByMedicineId(medicineId: Long): Result { - return awsNetworkApi.getCommentsByMedicineId(medicineId).onResponse().fold( + override suspend fun getCommentsByMedicineId(medicineId: Long, page: Int, rows: Int, userId: String): Result { + return awsNetworkApi.getCommentsByMedicineId(medicineId, page, rows, userId).onResponse().fold( onSuccess = { response -> if (response.commentList.isEmpty()) Result.failure(Exception("댓글이 없습니다.")) else Result.success(response) diff --git a/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsListDataSourceImpl.kt b/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsListDataSourceImpl.kt index f95337b5..c2c782b1 100644 --- a/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsListDataSourceImpl.kt +++ b/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsListDataSourceImpl.kt @@ -13,15 +13,18 @@ class CommentsListDataSourceImpl( override suspend fun load(params: LoadParams): LoadResult { return try { - commentsDataSource.getCommentsByMedicineId(medicineId).fold(onSuccess = { - LoadResult.Page( - data = it.commentList, - prevKey = null, - nextKey = if (it.commentList.size > 1000000) 1 else null, - ) - }, onFailure = { - LoadResult.Error(it) - }) + commentsDataSource.getCommentsByMedicineId(medicineId, 1, 15, "-1").fold( + onSuccess = { + LoadResult.Page( + data = it.commentList, + prevKey = null, + nextKey = if (it.commentList.size > 1000000) 1 else null, + ) + }, + onFailure = { + LoadResult.Error(it) + }, + ) } catch (e: Exception) { LoadResult.Error(e) }