From 835a6e1d4033c70416f12517b7f8d33d228a7ae3 Mon Sep 17 00:00:00 2001 From: SeongHoonC <108349655+SeongHoonC@users.noreply.github.com> Date: Sun, 7 Apr 2024 23:27:02 +0900 Subject: [PATCH] =?UTF-8?q?[AN/USER]=20feat:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20=EC=84=9C=EB=B2=84=EC=99=80=20=EC=97=B0=EA=B2=B0=ED=95=9C?= =?UTF-8?q?=EB=8B=A4(#830)=20(#834)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(repository): Default 가 접두사가 되도록 변경 * refactor(FestivalSearch): 축제 검색 객체 재생성 * refactor(response): API 명세에 맞게 이름 수정 * refactor(Module): 검색 원격 저장소 주입 * fest(Module): 아티스트 저장소 주입 * fest(Festival): 축제는 학교를 가지지 않을 수 있다 * fest(artist): 아티스트 상세 응답 받기 객체 정의 * fest(festival): 7 이하는 분홍색으로 표시한다 * fest(ArtistDetailViewModel): 데이터를 비동기로 요청한다 * fest(FestivalResponse): 학교를 가지지 않을 수 있다 * refactor(ArtistDetailViewModel): 아티스트 상세 비동기 호출 코드 정리 * refactor(ArtistSearchViewHolder): 공연 개수 길이에 따라 색깔이 바뀐다 * refactor(RepositoryModule): 축제 저장소 주입 이름 변경 Co-authored-by: 해시 <67777523+EmilyCh0@users.noreply.github.com> --------- Co-authored-by: 해시 <67777523+EmilyCh0@users.noreply.github.com> --- .../di/singletonscope/RepositoryModule.kt | 16 ++++---- .../data/di/singletonscope/ServiceModule.kt | 18 +++++++++ .../data/dto/artist/ArtistDetailResponse.kt | 22 +++++++++++ .../festago/data/dto/artist/ArtistResponse.kt | 4 +- .../data/dto/artist/ArtistSearchResponse.kt | 4 +- .../data/dto/festival/FestivalResponse.kt | 4 +- .../dto/festival/FestivalSearchResponse.kt | 25 ++++++++++++ .../festago/data/dto/school/SchoolResponse.kt | 4 +- .../SchoolFestivalArtistResponse.kt | 2 +- .../repository/DefaultArtistRepository.kt | 38 +++++++++++++++++++ ...sitory.kt => DefaultFestivalRepository.kt} | 2 +- ...pository.kt => DefaultSchoolRepository.kt} | 2 +- .../repository/DefaultSearchRepository.kt | 4 +- .../data/repository/FakeArtistRepository.kt | 14 +++++-- .../data/repository/FakeSearchRepository.kt | 6 +-- .../data/service/ArtistRetrofitService.kt | 26 +++++++++++++ .../data/service/SearchRetrofitService.kt | 4 +- .../domain/model/artist/ArtistDetail.kt | 6 ++- .../domain/model/artist/ArtistMedia.kt | 8 ---- .../festago/domain/model/festival/Festival.kt | 2 +- .../domain/model/search/FestivalSearch.kt | 13 +++++++ .../domain/repository/ArtistRepository.kt | 9 ++++- .../domain/repository/SearchRepository.kt | 4 +- .../ui/artistdetail/ArtistDetailViewModel.kt | 7 +++- .../ArtistDetailFestivalViewHolder.kt | 2 +- .../ui/artistdetail/uistate/SchoolUiState.kt | 6 --- .../festivallist/FestivalListViewModel.kt | 5 --- .../FestivalListFestivalViewHolder.kt | 2 +- .../uistate/FestivalItemUiState.kt | 1 - .../SchoolDetailFestivalViewHolder.kt | 4 +- .../ui/schooldetail/SchoolDetailViewModel.kt | 7 +--- .../uistate/FestivalItemUiState.kt | 1 - .../presentation/ui/search/SearchViewModel.kt | 9 +---- .../artistsearch/ArtistSearchViewHolder.kt | 2 +- .../uistate/FestivalSearchItemUiState.kt | 1 - .../res/layout/fragment_artist_detail.xml | 2 +- 36 files changed, 207 insertions(+), 79 deletions(-) create mode 100644 android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistDetailResponse.kt create mode 100644 android/festago/data/src/main/java/com/festago/festago/data/dto/festival/FestivalSearchResponse.kt create mode 100644 android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultArtistRepository.kt rename android/festago/data/src/main/java/com/festago/festago/data/repository/{FestivalDefaultRepository.kt => DefaultFestivalRepository.kt} (97%) rename android/festago/data/src/main/java/com/festago/festago/data/repository/{SchoolDefaultRepository.kt => DefaultSchoolRepository.kt} (96%) create mode 100644 android/festago/data/src/main/java/com/festago/festago/data/service/ArtistRetrofitService.kt delete mode 100644 android/festago/domain/src/main/java/com/festago/festago/domain/model/artist/ArtistMedia.kt create mode 100644 android/festago/domain/src/main/java/com/festago/festago/domain/model/search/FestivalSearch.kt delete mode 100644 android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/uistate/SchoolUiState.kt diff --git a/android/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt b/android/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt index 556bcf3da..4849994fc 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt @@ -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 @@ -22,15 +22,15 @@ 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 @@ -38,5 +38,5 @@ interface RepositoryModule { @Binds @Singleton - fun bindsSearchRepository(searchRepository: FakeSearchRepository): SearchRepository + fun bindsSearchRepository(searchRepository: DefaultSearchRepository): SearchRepository } diff --git a/android/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.kt b/android/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.kt index 0dc3d28e4..3c60c80e0 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.kt @@ -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 @@ -21,6 +23,14 @@ 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( @@ -28,4 +38,12 @@ object ServiceModule { ): SchoolRetrofitService { return retrofit.create(SchoolRetrofitService::class.java) } + + @Provides + @Singleton + fun providesSearchRetrofitService( + @NormalRetrofitQualifier retrofit: Retrofit, + ): SearchRetrofitService { + return retrofit.create(SearchRetrofitService::class.java) + } } diff --git a/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistDetailResponse.kt b/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistDetailResponse.kt new file mode 100644 index 000000000..3025956a9 --- /dev/null +++ b/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistDetailResponse.kt @@ -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, +) { + fun toDomain() = ArtistDetail( + id = id, + artistName = name ?: "", + profileUrl = profileImageUrl ?: "", + backgroundUrl = backgroundImageUrl ?: "", + artistMedia = socialMedias.map { it.toDomain() }, + ) +} diff --git a/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistResponse.kt b/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistResponse.kt index 2ff020431..f87a1026d 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistResponse.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistResponse.kt @@ -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, ) } diff --git a/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistSearchResponse.kt b/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistSearchResponse.kt index 098e28470..99e4db4fb 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistSearchResponse.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistSearchResponse.kt @@ -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, ) } diff --git a/android/festago/data/src/main/java/com/festago/festago/data/dto/festival/FestivalResponse.kt b/android/festago/data/src/main/java/com/festago/festago/data/dto/festival/FestivalResponse.kt index 8cbfda71b..65ca92527 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/dto/festival/FestivalResponse.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/dto/festival/FestivalResponse.kt @@ -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, ) { fun toDomain(): Festival = Festival( @@ -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() }, ) } diff --git a/android/festago/data/src/main/java/com/festago/festago/data/dto/festival/FestivalSearchResponse.kt b/android/festago/data/src/main/java/com/festago/festago/data/dto/festival/FestivalSearchResponse.kt new file mode 100644 index 000000000..acb3a9f52 --- /dev/null +++ b/android/festago/data/src/main/java/com/festago/festago/data/dto/festival/FestivalSearchResponse.kt @@ -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, +) { + fun toDomain(): FestivalSearch = FestivalSearch( + id = id, + name = name, + startDate = LocalDate.parse(startDate), + endDate = LocalDate.parse(endDate), + imageUrl = posterImageUrl, + artists = artists.map { it.toDomain() }, + ) +} diff --git a/android/festago/data/src/main/java/com/festago/festago/data/dto/school/SchoolResponse.kt b/android/festago/data/src/main/java/com/festago/festago/data/dto/school/SchoolResponse.kt index 3ea9ba949..70d309900 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/dto/school/SchoolResponse.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/dto/school/SchoolResponse.kt @@ -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, ) } diff --git a/android/festago/data/src/main/java/com/festago/festago/data/dto/schooldetail/SchoolFestivalArtistResponse.kt b/android/festago/data/src/main/java/com/festago/festago/data/dto/schooldetail/SchoolFestivalArtistResponse.kt index da5132deb..60c187114 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/dto/schooldetail/SchoolFestivalArtistResponse.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/dto/schooldetail/SchoolFestivalArtistResponse.kt @@ -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(), diff --git a/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultArtistRepository.kt b/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultArtistRepository.kt new file mode 100644 index 000000000..845213614 --- /dev/null +++ b/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultArtistRepository.kt @@ -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 { + return runCatchingResponse { artistRetrofitService.getArtistDetail(id) } + .onSuccessOrCatch { it.toDomain() } + } + + override suspend fun loadArtistFestivals( + id: Long, + size: Int?, + lastFestivalId: Long?, + lastStartDate: LocalDate?, + isPast: Boolean?, + ): Result { + return runCatchingResponse { + artistRetrofitService.getArtistFestivals( + artistId = id, + size = size, + lastFestivalId = lastFestivalId, + lastStartDate = lastStartDate, + isPast = isPast, + ) + }.onSuccessOrCatch { it.toDomain() } + } +} diff --git a/android/festago/data/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt b/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultFestivalRepository.kt similarity index 97% rename from android/festago/data/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt rename to android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultFestivalRepository.kt index 8b8dee5c1..28cda3afc 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultFestivalRepository.kt @@ -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 { diff --git a/android/festago/data/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt b/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultSchoolRepository.kt similarity index 96% rename from android/festago/data/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt rename to android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultSchoolRepository.kt index 9de6c9139..8bd0e488e 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultSchoolRepository.kt @@ -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 { diff --git a/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultSearchRepository.kt b/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultSearchRepository.kt index 322fbcb23..b3288ad5c 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultSearchRepository.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/repository/DefaultSearchRepository.kt @@ -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 @@ -13,7 +13,7 @@ class DefaultSearchRepository @Inject constructor( private val searchRetrofitService: SearchRetrofitService, ) : SearchRepository { - override suspend fun searchFestivals(searchQuery: String): Result> { + override suspend fun searchFestivals(searchQuery: String): Result> { return runCatchingResponse { searchRetrofitService.searchFestivals(searchQuery) }.onSuccessOrCatch { festivalResponses -> festivalResponses.map { it.toDomain() } } diff --git a/android/festago/data/src/main/java/com/festago/festago/data/repository/FakeArtistRepository.kt b/android/festago/data/src/main/java/com/festago/festago/data/repository/FakeArtistRepository.kt index 9e9ccefe9..2b01044d6 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/repository/FakeArtistRepository.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/repository/FakeArtistRepository.kt @@ -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 @@ -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", @@ -37,7 +37,13 @@ class FakeArtistRepository @Inject constructor() : ArtistRepository { ), ) - override suspend fun loadArtistFestivals(id: Long, size: Int): Result = + override suspend fun loadArtistFestivals( + id: Long, + size: Int?, + lastFestivalId: Long?, + lastStartDate: LocalDate?, + isPast: Boolean?, + ): Result = Result.success( FestivalsPage( isLastPage = false, diff --git a/android/festago/data/src/main/java/com/festago/festago/data/repository/FakeSearchRepository.kt b/android/festago/data/src/main/java/com/festago/festago/data/repository/FakeSearchRepository.kt index bb269124b..efe801fc0 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/repository/FakeSearchRepository.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/repository/FakeSearchRepository.kt @@ -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 @@ -10,11 +10,11 @@ import javax.inject.Inject class FakeSearchRepository @Inject constructor() : SearchRepository { private var times = 0 - override suspend fun searchFestivals(searchQuery: String): Result> { + override suspend fun searchFestivals(searchQuery: String): Result> { delay(1000) times++ if (times % 2 == 0) { - return Result.success(FakeFestivals.popularFestivals) + return Result.success(listOf()) } return Result.success(listOf()) } diff --git a/android/festago/data/src/main/java/com/festago/festago/data/service/ArtistRetrofitService.kt b/android/festago/data/src/main/java/com/festago/festago/data/service/ArtistRetrofitService.kt new file mode 100644 index 000000000..d8fc53a16 --- /dev/null +++ b/android/festago/data/src/main/java/com/festago/festago/data/service/ArtistRetrofitService.kt @@ -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 + + @GET("api/v1/artists/{artistId}") + suspend fun getArtistDetail( + @Path("artistId") artistId: Long, + ): Response +} diff --git a/android/festago/data/src/main/java/com/festago/festago/data/service/SearchRetrofitService.kt b/android/festago/data/src/main/java/com/festago/festago/data/service/SearchRetrofitService.kt index 794b43f9d..6f525f989 100644 --- a/android/festago/data/src/main/java/com/festago/festago/data/service/SearchRetrofitService.kt +++ b/android/festago/data/src/main/java/com/festago/festago/data/service/SearchRetrofitService.kt @@ -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 @@ -11,7 +11,7 @@ interface SearchRetrofitService { @GET("api/v1/search/festivals") suspend fun searchFestivals( @Query("keyword") keyword: String, - ): Response> + ): Response> @GET("api/v1/search/artists") suspend fun searchArtists( diff --git a/android/festago/domain/src/main/java/com/festago/festago/domain/model/artist/ArtistDetail.kt b/android/festago/domain/src/main/java/com/festago/festago/domain/model/artist/ArtistDetail.kt index c47db4176..69e40b2ae 100644 --- a/android/festago/domain/src/main/java/com/festago/festago/domain/model/artist/ArtistDetail.kt +++ b/android/festago/domain/src/main/java/com/festago/festago/domain/model/artist/ArtistDetail.kt @@ -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, + val artistMedia: List, ) diff --git a/android/festago/domain/src/main/java/com/festago/festago/domain/model/artist/ArtistMedia.kt b/android/festago/domain/src/main/java/com/festago/festago/domain/model/artist/ArtistMedia.kt deleted file mode 100644 index c2508219b..000000000 --- a/android/festago/domain/src/main/java/com/festago/festago/domain/model/artist/ArtistMedia.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.festago.festago.domain.model.artist - -data class ArtistMedia( - val type: String, - val name: String, - val logoUrl: String, - val url: String, -) diff --git a/android/festago/domain/src/main/java/com/festago/festago/domain/model/festival/Festival.kt b/android/festago/domain/src/main/java/com/festago/festago/domain/model/festival/Festival.kt index d1e0912db..cdc882891 100644 --- a/android/festago/domain/src/main/java/com/festago/festago/domain/model/festival/Festival.kt +++ b/android/festago/domain/src/main/java/com/festago/festago/domain/model/festival/Festival.kt @@ -10,6 +10,6 @@ data class Festival( val startDate: LocalDate, val endDate: LocalDate, val imageUrl: String, - val school: School, + val school: School?, val artists: List, ) diff --git a/android/festago/domain/src/main/java/com/festago/festago/domain/model/search/FestivalSearch.kt b/android/festago/domain/src/main/java/com/festago/festago/domain/model/search/FestivalSearch.kt new file mode 100644 index 000000000..00d06acd2 --- /dev/null +++ b/android/festago/domain/src/main/java/com/festago/festago/domain/model/search/FestivalSearch.kt @@ -0,0 +1,13 @@ +package com.festago.festago.domain.model.search + +import com.festago.festago.domain.model.artist.Artist +import java.time.LocalDate + +data class FestivalSearch( + val id: Long, + val name: String, + val startDate: LocalDate, + val endDate: LocalDate, + val imageUrl: String, + val artists: List, +) diff --git a/android/festago/domain/src/main/java/com/festago/festago/domain/repository/ArtistRepository.kt b/android/festago/domain/src/main/java/com/festago/festago/domain/repository/ArtistRepository.kt index a49d3f194..31afb9b17 100644 --- a/android/festago/domain/src/main/java/com/festago/festago/domain/repository/ArtistRepository.kt +++ b/android/festago/domain/src/main/java/com/festago/festago/domain/repository/ArtistRepository.kt @@ -2,9 +2,16 @@ package com.festago.festago.domain.repository import com.festago.festago.domain.model.artist.ArtistDetail import com.festago.festago.domain.model.festival.FestivalsPage +import java.time.LocalDate interface ArtistRepository { suspend fun loadArtistDetail(id: Long): Result - suspend fun loadArtistFestivals(id: Long, size: Int): Result + suspend fun loadArtistFestivals( + id: Long, + size: Int? = null, + lastFestivalId: Long? = null, + lastStartDate: LocalDate? = null, + isPast: Boolean? = null, + ): Result } diff --git a/android/festago/domain/src/main/java/com/festago/festago/domain/repository/SearchRepository.kt b/android/festago/domain/src/main/java/com/festago/festago/domain/repository/SearchRepository.kt index b2129f848..276707831 100644 --- a/android/festago/domain/src/main/java/com/festago/festago/domain/repository/SearchRepository.kt +++ b/android/festago/domain/src/main/java/com/festago/festago/domain/repository/SearchRepository.kt @@ -1,11 +1,11 @@ package com.festago.festago.domain.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 interface SearchRepository { - suspend fun searchFestivals(searchQuery: String): Result> + suspend fun searchFestivals(searchQuery: String): Result> suspend fun searchArtists(searchQuery: String): Result> suspend fun searchSchools(searchQuery: String): Result> } diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt index 503779bd7..0b33d2a78 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt @@ -8,6 +8,7 @@ import com.festago.festago.presentation.ui.artistdetail.uistate.ArtistDetailUiSt import com.festago.festago.presentation.ui.artistdetail.uistate.ArtistUiState import com.festago.festago.presentation.ui.artistdetail.uistate.FestivalItemUiState import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow @@ -33,9 +34,11 @@ class ArtistDetailViewModel @Inject constructor( viewModelScope.launch { runCatching { + val deferredArtistDetail = async { artistRepository.loadArtistDetail(id) } + val deferredFestivals = async { artistRepository.loadArtistFestivals(id, 10) } _uiState.value = ArtistDetailUiState.Success( - artistRepository.loadArtistDetail(id).getOrThrow(), - artistRepository.loadArtistFestivals(id, 20).getOrThrow().toUiState(), + deferredArtistDetail.await().getOrThrow(), + deferredFestivals.await().getOrThrow().toUiState(), ) }.onFailure { _uiState.value = ArtistDetailUiState.Error diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/adapter/festival/ArtistDetailFestivalViewHolder.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/adapter/festival/ArtistDetailFestivalViewHolder.kt index 35696e39c..59999b4c4 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/adapter/festival/ArtistDetailFestivalViewHolder.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/adapter/festival/ArtistDetailFestivalViewHolder.kt @@ -47,7 +47,7 @@ class ArtistDetailFestivalViewHolder(private val binding: ItemArtistDetailFestiv ) } - LocalDate.now() == item.startDate.minusDays(1) -> { + LocalDate.now() >= item.startDate.minusDays(7) -> { dDayView.text = context.getString( R.string.artist_detail_tv_dday_format, item.startDate.compareTo(LocalDate.now()).toString(), diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/uistate/SchoolUiState.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/uistate/SchoolUiState.kt deleted file mode 100644 index d8f34a721..000000000 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/uistate/SchoolUiState.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.festago.festago.presentation.ui.artistdetail.uistate - -data class SchoolUiState( - val id: Long, - val name: String, -) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt index 2b96deedd..6a380b740 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt @@ -13,7 +13,6 @@ import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalFil import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalItemUiState import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalListUiState import com.festago.festago.presentation.ui.home.festivallist.uistate.PopularFestivalUiState -import com.festago.festago.presentation.ui.home.festivallist.uistate.SchoolUiState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableSharedFlow @@ -152,10 +151,6 @@ class FestivalListViewModel @Inject constructor( startDate = startDate, endDate = endDate, imageUrl = imageUrl, - schoolUiState = SchoolUiState( - id = school.id, - name = school.name, - ), artists = artists.map { artist -> ArtistUiState(artist.id, artist.name, artist.imageUrl) }, diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/festival/FestivalListFestivalViewHolder.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/festival/FestivalListFestivalViewHolder.kt index 8ff856c0b..3ef86e217 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/festival/FestivalListFestivalViewHolder.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/festival/FestivalListFestivalViewHolder.kt @@ -49,7 +49,7 @@ class FestivalListFestivalViewHolder( ) } - LocalDate.now() == item.startDate.minusDays(1) -> { + LocalDate.now() >= item.startDate.minusDays(7) -> { dDayView.setTextColor(context.getColor(R.color.background_gray_01)) dDayView.text = context.getString( R.string.festival_list_tv_dday_format, diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/uistate/FestivalItemUiState.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/uistate/FestivalItemUiState.kt index ba83253a2..5f35701f1 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/uistate/FestivalItemUiState.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/uistate/FestivalItemUiState.kt @@ -8,7 +8,6 @@ data class FestivalItemUiState( val startDate: LocalDate, val endDate: LocalDate, val imageUrl: String, - val schoolUiState: SchoolUiState, val artists: List, val onFestivalDetail: (festivalId: Long) -> Unit, ) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailFestivalViewHolder.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailFestivalViewHolder.kt index 8c145006c..e16c9bf28 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailFestivalViewHolder.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailFestivalViewHolder.kt @@ -15,7 +15,7 @@ import com.festago.festago.presentation.ui.schooldetail.uistate.FestivalItemUiSt import java.time.LocalDate class SchoolDetailFestivalViewHolder( - private val binding: ItemSchoolDetailFestivalBinding + private val binding: ItemSchoolDetailFestivalBinding, ) : RecyclerView.ViewHolder(binding.root) { private val artistAdapter = ArtistAdapter() @@ -46,7 +46,7 @@ class SchoolDetailFestivalViewHolder( ) } - LocalDate.now() == item.startDate.minusDays(1) -> { + LocalDate.now() >= item.startDate.minusDays(7) -> { dDayView.setTextColor(context.getColor(R.color.background_gray_01)) dDayView.text = context.getString( R.string.festival_list_tv_dday_format, diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailViewModel.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailViewModel.kt index 7f4804934..562fc90f2 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailViewModel.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailViewModel.kt @@ -9,7 +9,6 @@ import com.festago.festago.domain.repository.SchoolRepository import com.festago.festago.presentation.ui.schooldetail.uistate.ArtistUiState import com.festago.festago.presentation.ui.schooldetail.uistate.FestivalItemUiState import com.festago.festago.presentation.ui.schooldetail.uistate.SchoolDetailUiState -import com.festago.festago.presentation.ui.schooldetail.uistate.SchoolUiState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableStateFlow @@ -39,7 +38,7 @@ class SchoolDetailViewModel @Inject constructor( _uiState.value = SchoolDetailUiState.Success( schoolInfo = schoolInfo, festivals = festivalPage.festivals.map { it.toUiState() }, - isLast = festivalPage.isLastPage + isLast = festivalPage.isLastPage, ) }.onFailure { _uiState.value = SchoolDetailUiState.Error @@ -57,10 +56,6 @@ class SchoolDetailViewModel @Inject constructor( startDate = startDate, endDate = endDate, imageUrl = imageUrl, - schoolUiState = SchoolUiState( - id = school.id, - name = school.name, - ), artists = artists.map { artist -> ArtistUiState(artist.id, artist.name, artist.imageUrl) }, diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/uistate/FestivalItemUiState.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/uistate/FestivalItemUiState.kt index 626a3bd97..246165d63 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/uistate/FestivalItemUiState.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/uistate/FestivalItemUiState.kt @@ -8,6 +8,5 @@ data class FestivalItemUiState( val startDate: LocalDate, val endDate: LocalDate, val imageUrl: String, - val schoolUiState: SchoolUiState, val artists: List, ) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/SearchViewModel.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/SearchViewModel.kt index 58e02f39d..74a950c19 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/SearchViewModel.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/SearchViewModel.kt @@ -4,9 +4,9 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.festago.festago.common.analytics.AnalyticsHelper import com.festago.festago.common.analytics.logNetworkFailure -import com.festago.festago.domain.model.festival.Festival import com.festago.festago.domain.model.recentsearch.RecentSearchQuery 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.RecentSearchRepository import com.festago.festago.domain.repository.SearchRepository @@ -17,7 +17,6 @@ import com.festago.festago.presentation.ui.search.uistate.ArtistUiState import com.festago.festago.presentation.ui.search.uistate.FestivalSearchItemUiState import com.festago.festago.presentation.ui.search.uistate.RecentSearchItemUiState import com.festago.festago.presentation.ui.search.uistate.SchoolSearchItemUiState -import com.festago.festago.presentation.ui.search.uistate.SchoolUiState import com.festago.festago.presentation.ui.search.uistate.SearchUiState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.async @@ -102,16 +101,12 @@ class SearchViewModel @Inject constructor( onRecentSearchDeleted = ::deleteRecentSearch, ) - private fun Festival.toUiState() = FestivalSearchItemUiState( + private fun FestivalSearch.toUiState() = FestivalSearchItemUiState( id = id, name = name, startDate = startDate, endDate = endDate, imageUrl = imageUrl, - schoolUiState = SchoolUiState( - id = school.id, - name = school.name, - ), artists = artists.map { artist -> ArtistUiState(artist.id, artist.name, artist.imageUrl, ::showArtistDetail) }, diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/artistsearch/ArtistSearchViewHolder.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/artistsearch/ArtistSearchViewHolder.kt index 5f74472e8..01318c966 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/artistsearch/ArtistSearchViewHolder.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/artistsearch/ArtistSearchViewHolder.kt @@ -34,7 +34,7 @@ class ArtistSearchViewHolder( text = SpannableString(stageCountText).apply { getPartialColorText( start = COLOR_INDEX, - end = COLOR_INDEX + 1, + end = COLOR_INDEX + count.toString().length, color = context.getColor(R.color.secondary_pink_01), ) } diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/uistate/FestivalSearchItemUiState.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/uistate/FestivalSearchItemUiState.kt index 218141b52..89876b681 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/uistate/FestivalSearchItemUiState.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/search/uistate/FestivalSearchItemUiState.kt @@ -8,7 +8,6 @@ data class FestivalSearchItemUiState( val startDate: LocalDate, val endDate: LocalDate, val imageUrl: String, - val schoolUiState: SchoolUiState, val artists: List, val onFestivalSearchClick: (festivalId: Long) -> Unit, ) diff --git a/android/festago/presentation/src/main/res/layout/fragment_artist_detail.xml b/android/festago/presentation/src/main/res/layout/fragment_artist_detail.xml index 9c9daa8b9..1d756777b 100644 --- a/android/festago/presentation/src/main/res/layout/fragment_artist_detail.xml +++ b/android/festago/presentation/src/main/res/layout/fragment_artist_detail.xml @@ -69,7 +69,7 @@