Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AN] 홈뷰 구조 리팩터링 #594

Merged
merged 18 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ interface DataSourceModule {
@Singleton
@Binds
fun bindDefaultTokenDataSource(defaultTokenDataSource: DefaultTokenDataSource): TokenDataSource

}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.created.team201.data.di

import android.util.Log
import com.created.domain.repository.AuthRepository
import com.created.team201.BuildConfig.TEAM201_BASE_URL
import com.created.team201.data.di.qualifier.AuthRetrofit
import com.created.team201.data.di.qualifier.DefaultRetrofit
import com.created.team201.data.remote.CallAdapterFactory
import com.created.team201.data.remote.interceptor.AuthInterceptor
import com.created.team201.data.repository.AuthRepository
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import dagger.Module
import dagger.Provides
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package com.created.team201.data.di

import com.created.team201.data.datasource.local.OnBoardingDataSource
import com.created.team201.data.datasource.local.TokenDataSource
import com.created.team201.data.remote.api.AuthService
import com.created.team201.data.remote.api.CertificationService
import com.created.team201.data.remote.api.CommonStudyListService
import com.created.team201.data.remote.api.CreateStudyService
import com.created.team201.data.remote.api.ImageService
import com.created.team201.data.remote.api.MemberStudyListService
import com.created.team201.data.remote.api.MyPageService
import com.created.team201.data.remote.api.OnBoardingService
import com.created.team201.data.remote.api.ProfileService
import com.created.team201.data.remote.api.ReportService
import com.created.team201.data.remote.api.SettingService
import com.created.team201.data.remote.api.StudyDetailService
import com.created.team201.data.remote.api.ThreadService
import com.created.team201.data.remote.api.UserStudyService
import com.created.team201.data.repository.AuthRepository
import com.created.team201.data.repository.CertificationRepository
import com.created.team201.data.repository.CreateStudyRepository
import com.created.team201.data.repository.GuestRepository
import com.created.team201.data.repository.MyPageRepository
import com.created.team201.data.repository.OnBoardingRepository
import com.created.team201.data.repository.ProfileRepository
import com.created.team201.data.repository.ReportRepository
import com.created.team201.data.repository.SettingRepository
import com.created.team201.data.repository.SplashRepository
import com.created.team201.data.repository.StudyDetailRepository
import com.created.team201.data.repository.StudyListRepository
import com.created.team201.data.repository.ThreadRepository
import com.created.team201.data.repository.UserStudyRepository
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ProvidedRepositoryModule {

@Provides
@Singleton
fun providesUserStudyRepository(
userStudyService: UserStudyService,
): UserStudyRepository = UserStudyRepository(userStudyService)

@Provides
@Singleton
fun providesAuthRepository(
authService: AuthService,
tokenDataSource: TokenDataSource,
): AuthRepository = AuthRepository(authService, tokenDataSource)

@Provides
@Singleton
fun providesCertificationRepository(
imageService: ImageService,
certificationService: CertificationService,
): CertificationRepository = CertificationRepository(imageService, certificationService)

@Provides
@Singleton
fun providesCreateStudyRepository(
createStudyService: CreateStudyService,
): CreateStudyRepository = CreateStudyRepository(createStudyService)

@Provides
@Singleton
fun providesGuestRepository(
tokenDataSource: TokenDataSource,
onBoardingDataSource: OnBoardingDataSource,
): GuestRepository = GuestRepository(tokenDataSource, onBoardingDataSource)

@Provides
@Singleton
fun providesMyPageRepository(
myPageService: MyPageService,
): MyPageRepository = MyPageRepository(myPageService)

@Provides
@Singleton
fun providesOnBoardingRepository(
onBoardingDataSource: OnBoardingDataSource,
onBoardingService: OnBoardingService,
): OnBoardingRepository = OnBoardingRepository(onBoardingDataSource, onBoardingService)

@Provides
@Singleton
fun providesProfileRepository(
profileService: ProfileService,
): ProfileRepository = ProfileRepository(profileService)

@Provides
@Singleton
fun providesReportRepository(
reportService: ReportService,
): ReportRepository = ReportRepository(reportService)

@Provides
@Singleton
fun providesSettingRepository(
onBoardingDataSource: OnBoardingDataSource,
settingService: SettingService,
tokenDataSource: TokenDataSource,
): SettingRepository = SettingRepository(onBoardingDataSource, settingService, tokenDataSource)

@Provides
@Singleton
fun providesSplashRepository(): SplashRepository = SplashRepository()

@Provides
@Singleton
fun providesStudyDetailRepository(
studyDetailService: StudyDetailService,
): StudyDetailRepository = StudyDetailRepository(studyDetailService)

@Provides
@Singleton
fun providesStudyListRepository(
commonStudyListService: CommonStudyListService,
memberStudyListService: MemberStudyListService,
): StudyListRepository = StudyListRepository(commonStudyListService, memberStudyListService)

@Provides
@Singleton
fun providesThreadRepository(
threadService: ThreadService,
): ThreadRepository = ThreadRepository(threadService)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.created.team201.data.remote.api.AuthService
import com.created.team201.data.remote.api.CertificationService
import com.created.team201.data.remote.api.CommonStudyListService
import com.created.team201.data.remote.api.CreateStudyService
import com.created.team201.data.remote.api.HomeService
import com.created.team201.data.remote.api.ImageService
import com.created.team201.data.remote.api.MemberStudyListService
import com.created.team201.data.remote.api.MyPageService
Expand All @@ -17,6 +16,7 @@ import com.created.team201.data.remote.api.SettingService
import com.created.team201.data.remote.api.StudyDetailService
import com.created.team201.data.remote.api.ThreadService
import com.created.team201.data.remote.api.UpdateStudyService
import com.created.team201.data.remote.api.UserStudyService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -55,8 +55,8 @@ object ServiceModule {

@Singleton
@Provides
fun provideHomeService(@AuthRetrofit retrofit: Retrofit): HomeService =
retrofit.create(HomeService::class.java)
fun provideUserStudyService(@AuthRetrofit retrofit: Retrofit): UserStudyService =
retrofit.create(UserStudyService::class.java)

@Singleton
@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ fun MustDoCertificationResponseDto.toDomain(): MustDoCertification = MustDoCerti
me = me.toMustDo(),
others = others.map { it.toMustDo() },

)
)

fun MustDoCertificationResponseDto.UpcomingRound.toUpcomingRound(): MustDoCertification.UpcomingRound =
MustDoCertification.UpcomingRound(
id = id,
weekNumber = weekNumber,

)
)

fun MustDoCertificationResponseDto.User.toMustDo(): MustDo = MustDo(
id = id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.created.team201.data.mapper

import com.created.domain.model.UserStudy
import com.created.team201.data.remote.response.HomeStudyResponseDto
import com.created.team201.data.model.UserStudyEntity
import com.created.team201.data.remote.response.UserStudyResponseDto


fun HomeStudyResponseDto.toUserStudy(): UserStudy =
UserStudy(
fun UserStudyResponseDto.toUserStudyEntity(): UserStudyEntity =
UserStudyEntity(
isMaster = isMaster,
studyId = studyId,
studyName = studyName,
mustDo = mustDo ?: "",
leftDays = leftDays,
grassSeedsCount = grassSeedsCount,
)
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.created.domain.model
package com.created.team201.data.model

data class UserStudy(
data class UserStudyEntity(
val studyId: Long,
val studyName: String,
val mustDo: String,
val leftDays: Int,
val grassSeedsCount: Int,
val isMaster: Boolean
val isMaster: Boolean,
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.created.team201.data.remote.api

import com.created.team201.data.remote.response.UserStudyResponseDto
import retrofit2.http.GET

interface UserStudyService {

@GET("v1/home")
suspend fun getUserStudies(): List<UserStudyResponseDto>
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.created.team201.data.remote.interceptor

import android.util.Log
import com.created.domain.repository.AuthRepository
import com.created.team201.data.repository.AuthRepository
import kotlinx.coroutines.runBlocking
import okhttp3.Interceptor
import okhttp3.Response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class HomeStudyResponseDto(
data class UserStudyResponseDto(
@SerialName("id")
val studyId: Long,
@SerialName("name")
Expand Down
Loading