Skip to content

Commit

Permalink
feat(DefaultSearchRepository): 검색 저장소 정의
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongHoonC committed Mar 20, 2024
1 parent 42bac4b commit 9231234
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.festago.festago.data.repository

import com.festago.festago.data.service.SearchRetrofitService
import com.festago.festago.data.util.onSuccessOrCatch
import com.festago.festago.data.util.runCatchingResponse
import com.festago.festago.domain.model.festival.Festival
import com.festago.festago.domain.model.search.ArtistSearch
import com.festago.festago.domain.model.search.SchoolSearch
import com.festago.festago.domain.repository.SearchRepository
import javax.inject.Inject

class DefaultSearchRepository @Inject constructor(
private val searchRetrofitService: SearchRetrofitService,
) : SearchRepository {

override suspend fun searchFestivals(searchQuery: String): Result<List<Festival>> {
return runCatchingResponse { searchRetrofitService.searchFestivals(searchQuery) }.onSuccessOrCatch { festivalResponses ->
festivalResponses.map { it.toDomain() }
}
}

override suspend fun searchArtists(searchQuery: String): Result<List<ArtistSearch>> {
return runCatchingResponse {
searchRetrofitService.searchArtists(searchQuery)
}.onSuccessOrCatch { artistSearchResponses -> artistSearchResponses.map { it.toDomain() } }
}

override suspend fun searchSchools(searchQuery: String): Result<List<SchoolSearch>> {
return runCatchingResponse {
searchRetrofitService.searchSchools(searchQuery)
}.onSuccessOrCatch { schoolSearchResponses -> schoolSearchResponses.map { it.toDomain() } }
}
}

0 comments on commit 9231234

Please sign in to comment.