Skip to content

Commit

Permalink
Merge branch 'dev' into feat/#819
Browse files Browse the repository at this point in the history
# Conflicts:
#	backend/src/test/java/com/festago/artist/repository/MemoryArtistRepository.java
  • Loading branch information
seokjin8678 committed Apr 8, 2024
2 parents b7c3e8d + 835a6e1 commit 1824ebc
Show file tree
Hide file tree
Showing 46 changed files with 516 additions and 176 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.festago.festago.data.di.singletonscope

import com.festago.festago.data.repository.DefaultArtistRepository
import com.festago.festago.data.repository.DefaultFestivalRepository
import com.festago.festago.data.repository.DefaultRecentSearchRepository
import com.festago.festago.data.repository.FakeArtistRepository
import com.festago.festago.data.repository.FakeFestivalRepository
import com.festago.festago.data.repository.FakeSchoolRepository
import com.festago.festago.data.repository.FakeSearchRepository
import com.festago.festago.data.repository.DefaultSchoolRepository
import com.festago.festago.data.repository.DefaultSearchRepository
import com.festago.festago.domain.repository.ArtistRepository
import com.festago.festago.domain.repository.FestivalRepository
import com.festago.festago.domain.repository.RecentSearchRepository
Expand All @@ -22,21 +22,21 @@ interface RepositoryModule {

@Binds
@Singleton
fun bindsFestivalDefaultRepository(festivalRepository: FakeFestivalRepository): FestivalRepository
fun bindsFestivalRepository(festivalRepository: DefaultFestivalRepository): FestivalRepository

@Binds
@Singleton
fun bindsArtistRepository(artistRepository: FakeArtistRepository): ArtistRepository
fun bindsArtistRepository(artistRepository: DefaultArtistRepository): ArtistRepository

@Binds
@Singleton
fun bindsSchoolRepository(schoolRepository: FakeSchoolRepository): SchoolRepository
fun bindsSchoolRepository(schoolRepository: DefaultSchoolRepository): SchoolRepository

@Binds
@Singleton
fun bindsRecentSearchRepository(recentSearchRepository: DefaultRecentSearchRepository): RecentSearchRepository

@Binds
@Singleton
fun bindsSearchRepository(searchRepository: FakeSearchRepository): SearchRepository
fun bindsSearchRepository(searchRepository: DefaultSearchRepository): SearchRepository
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.festago.festago.data.di.singletonscope

import com.festago.festago.data.service.ArtistRetrofitService
import com.festago.festago.data.service.FestivalRetrofitService
import com.festago.festago.data.service.SchoolRetrofitService
import com.festago.festago.data.service.SearchRetrofitService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand All @@ -21,11 +23,27 @@ object ServiceModule {
return retrofit.create(FestivalRetrofitService::class.java)
}

@Provides
@Singleton
fun providesArtistRetrofitService(
@NormalRetrofitQualifier retrofit: Retrofit,
): ArtistRetrofitService {
return retrofit.create(ArtistRetrofitService::class.java)
}

@Provides
@Singleton
fun providesSchoolRetrofitService(
@NormalRetrofitQualifier retrofit: Retrofit,
): SchoolRetrofitService {
return retrofit.create(SchoolRetrofitService::class.java)
}

@Provides
@Singleton
fun providesSearchRetrofitService(
@NormalRetrofitQualifier retrofit: Retrofit,
): SearchRetrofitService {
return retrofit.create(SearchRetrofitService::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.festago.festago.data.dto.artist

import com.festago.festago.data.dto.school.SocialMediaResponse
import com.festago.festago.domain.model.artist.ArtistDetail
import kotlinx.serialization.Serializable

@Serializable
data class ArtistDetailResponse(
val id: Int,
val name: String?,
val profileImageUrl: String?,
val backgroundImageUrl: String?,
val socialMedias: List<SocialMediaResponse>,
) {
fun toDomain() = ArtistDetail(
id = id,
artistName = name ?: "",
profileUrl = profileImageUrl ?: "",
backgroundUrl = backgroundImageUrl ?: "",
artistMedia = socialMedias.map { it.toDomain() },
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import kotlinx.serialization.Serializable
data class ArtistResponse(
val id: Long,
val name: String,
val profileImage: String,
val profileImageUrl: String,
) {
fun toDomain() = Artist(
id = id,
name = name,
imageUrl = profileImage,
imageUrl = profileImageUrl,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ data class ArtistSearchResponse(
val name: String,
val profileImageUrl: String,
val todayStage: Int,
val upcomingStage: Int,
val plannedStage: Int,
) {
fun toDomain() = ArtistSearch(
id = id,
name = name,
profileImageUrl = profileImageUrl,
todayStage = todayStage,
upcomingStage = upcomingStage,
upcomingStage = plannedStage,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data class FestivalResponse(
val startDate: String,
val endDate: String,
val posterImageUrl: String,
val school: SchoolResponse,
val school: SchoolResponse? = null,
val artists: List<ArtistResponse>,
) {
fun toDomain(): Festival = Festival(
Expand All @@ -22,7 +22,7 @@ data class FestivalResponse(
startDate = LocalDate.parse(startDate),
endDate = LocalDate.parse(endDate),
imageUrl = posterImageUrl,
school = school.toDomain(),
school = school?.toDomain(),
artists = artists.map { it.toDomain() },
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.festago.festago.data.dto.festival

import com.festago.festago.data.dto.artist.ArtistResponse
import com.festago.festago.domain.model.search.FestivalSearch
import kotlinx.serialization.Serializable
import java.time.LocalDate

@Serializable
data class FestivalSearchResponse(
val id: Long,
val name: String,
val startDate: String,
val endDate: String,
val posterImageUrl: String,
val artists: List<ArtistResponse>,
) {
fun toDomain(): FestivalSearch = FestivalSearch(
id = id,
name = name,
startDate = LocalDate.parse(startDate),
endDate = LocalDate.parse(endDate),
imageUrl = posterImageUrl,
artists = artists.map { it.toDomain() },
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import kotlinx.serialization.Serializable
data class SchoolResponse(
val id: Long,
val name: String,
val imageUrl: String = "",
val profileImageUrl: String = "",
) {
fun toDomain() = School(
id = id,
name = name,
imageUrl = imageUrl,
imageUrl = profileImageUrl,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import kotlinx.serialization.Serializable
data class SchoolFestivalArtistResponse(
val id: Int,
val name: String,
val profileImageUrl: String
val profileImageUrl: String,
) {
fun toDomain() = Artist(
id = id.toLong(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.festago.festago.data.repository

import com.festago.festago.data.service.ArtistRetrofitService
import com.festago.festago.data.util.onSuccessOrCatch
import com.festago.festago.data.util.runCatchingResponse
import com.festago.festago.domain.model.artist.ArtistDetail
import com.festago.festago.domain.model.festival.FestivalsPage
import com.festago.festago.domain.repository.ArtistRepository
import java.time.LocalDate
import javax.inject.Inject

class DefaultArtistRepository @Inject constructor(
private val artistRetrofitService: ArtistRetrofitService,
) : ArtistRepository {

override suspend fun loadArtistDetail(id: Long): Result<ArtistDetail> {
return runCatchingResponse { artistRetrofitService.getArtistDetail(id) }
.onSuccessOrCatch { it.toDomain() }
}

override suspend fun loadArtistFestivals(
id: Long,
size: Int?,
lastFestivalId: Long?,
lastStartDate: LocalDate?,
isPast: Boolean?,
): Result<FestivalsPage> {
return runCatchingResponse {
artistRetrofitService.getArtistFestivals(
artistId = id,
size = size,
lastFestivalId = lastFestivalId,
lastStartDate = lastStartDate,
isPast = isPast,
)
}.onSuccessOrCatch { it.toDomain() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.festago.festago.domain.repository.FestivalRepository
import java.time.LocalDate
import javax.inject.Inject

class FestivalDefaultRepository @Inject constructor(
class DefaultFestivalRepository @Inject constructor(
private val festivalRetrofitService: FestivalRetrofitService,
) : FestivalRepository {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.festago.festago.domain.repository.SchoolRepository
import java.time.LocalDate
import javax.inject.Inject

class SchoolDefaultRepository @Inject constructor(
class DefaultSchoolRepository @Inject constructor(
private val schoolRetrofitService: SchoolRetrofitService
) : SchoolRepository {
override suspend fun loadSchoolInfo(schoolId: Long): Result<SchoolInfo> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ 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.FestivalSearch
import com.festago.festago.domain.model.search.SchoolSearch
import com.festago.festago.domain.repository.SearchRepository
import javax.inject.Inject
Expand All @@ -13,7 +13,7 @@ class DefaultSearchRepository @Inject constructor(
private val searchRetrofitService: SearchRetrofitService,
) : SearchRepository {

override suspend fun searchFestivals(searchQuery: String): Result<List<Festival>> {
override suspend fun searchFestivals(searchQuery: String): Result<List<FestivalSearch>> {
return runCatchingResponse { searchRetrofitService.searchFestivals(searchQuery) }.onSuccessOrCatch { festivalResponses ->
festivalResponses.map { it.toDomain() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package com.festago.festago.data.repository

import com.festago.festago.domain.model.artist.Artist
import com.festago.festago.domain.model.artist.ArtistDetail
import com.festago.festago.domain.model.artist.ArtistMedia
import com.festago.festago.domain.model.festival.Festival
import com.festago.festago.domain.model.festival.FestivalsPage
import com.festago.festago.domain.model.school.School
import com.festago.festago.domain.model.social.SocialMedia
import com.festago.festago.domain.repository.ArtistRepository
import java.time.LocalDate
import javax.inject.Inject
Expand All @@ -21,13 +21,13 @@ class FakeArtistRepository @Inject constructor() : ArtistRepository {
"https://static.wikia.nocookie.net/witchers/images/d/d9/New_Jeans_Cover.png/revision/latest?cb=20220801091438",
"https://static.wikia.nocookie.net/witchers/images/d/d9/New_Jeans_Cover.png/revision/latest?cb=20220801091438",
listOf(
ArtistMedia(
SocialMedia(
"https://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Instagram_icon.png/1200px-Instagram_icon.png?20200512141346",
"공식 인스타그램",
"https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Instagram_logo_2016.svg/264px-Instagram_logo_2016.svg.png",
"https://www.instagram.com/newjeans_official/",
),
ArtistMedia(
SocialMedia(
"https://upload.wikimedia.org/wikipedia/commons/thumb/c/ce/X_logo_2023.svg/600px-X_logo_2023.svg.png?20230819000805",
"공식 엑스",
"https://upload.wikimedia.org/wikipedia/commons/thumb/c/ce/X_logo_2023.svg/531px-X_logo_2023.svg.png",
Expand All @@ -37,7 +37,13 @@ class FakeArtistRepository @Inject constructor() : ArtistRepository {
),
)

override suspend fun loadArtistFestivals(id: Long, size: Int): Result<FestivalsPage> =
override suspend fun loadArtistFestivals(
id: Long,
size: Int?,
lastFestivalId: Long?,
lastStartDate: LocalDate?,
isPast: Boolean?,
): Result<FestivalsPage> =
Result.success(
FestivalsPage(
isLastPage = false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.festago.festago.data.repository

import com.festago.festago.domain.model.festival.Festival
import com.festago.festago.domain.model.search.ArtistSearch
import com.festago.festago.domain.model.search.FestivalSearch
import com.festago.festago.domain.model.search.SchoolSearch
import com.festago.festago.domain.repository.SearchRepository
import kotlinx.coroutines.delay
Expand All @@ -10,11 +10,11 @@ import javax.inject.Inject

class FakeSearchRepository @Inject constructor() : SearchRepository {
private var times = 0
override suspend fun searchFestivals(searchQuery: String): Result<List<Festival>> {
override suspend fun searchFestivals(searchQuery: String): Result<List<FestivalSearch>> {
delay(1000)
times++
if (times % 2 == 0) {
return Result.success(FakeFestivals.popularFestivals)
return Result.success(listOf())
}
return Result.success(listOf())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.festago.festago.data.service

import com.festago.festago.data.dto.artist.ArtistDetailResponse
import com.festago.festago.data.dto.festival.FestivalsResponse
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query
import java.time.LocalDate

interface ArtistRetrofitService {

@GET("api/v1/artists/{artistId}/festivals")
suspend fun getArtistFestivals(
@Path("artistId") artistId: Long,
@Query("size") size: Int?,
@Query("lastFestivalId") lastFestivalId: Long?,
@Query("lastStartDate") lastStartDate: LocalDate?,
@Query("isPast") isPast: Boolean?,
): Response<FestivalsResponse>

@GET("api/v1/artists/{artistId}")
suspend fun getArtistDetail(
@Path("artistId") artistId: Long,
): Response<ArtistDetailResponse>
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.festago.festago.data.service

import com.festago.festago.data.dto.artist.ArtistSearchResponse
import com.festago.festago.data.dto.festival.FestivalResponse
import com.festago.festago.data.dto.festival.FestivalSearchResponse
import com.festago.festago.data.dto.school.SchoolSearchResponse
import retrofit2.Response
import retrofit2.http.GET
Expand All @@ -11,7 +11,7 @@ interface SearchRetrofitService {
@GET("api/v1/search/festivals")
suspend fun searchFestivals(
@Query("keyword") keyword: String,
): Response<List<FestivalResponse>>
): Response<List<FestivalSearchResponse>>

@GET("api/v1/search/artists")
suspend fun searchArtists(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.festago.festago.domain.model.artist

import com.festago.festago.domain.model.social.SocialMedia

data class ArtistDetail(
val id: Int,
val artistName: String,
val logoUrl: String,
val profileUrl: String,
val backgroundUrl: String,
val artistMedia: List<ArtistMedia>,
val artistMedia: List<SocialMedia>,
)
Loading

0 comments on commit 1824ebc

Please sign in to comment.