Skip to content

Commit

Permalink
refactor: Clean Architecture 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
comst19 committed Jan 10, 2024
1 parent 42c3817 commit 5e2f37e
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.droidblossom.archive.data.model.sms_message

data class SMSRequestData(
val phoneNumber: String,
val deviceId: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.droidblossom.archive.data.model.sms_message

data class SMSVerificationResponse(
val code : String,
// 시간, 번호, 등등?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.droidblossom.archive.data.repository

import com.droidblossom.archive.data.source.remote.api.SMSMessageService
import com.droidblossom.archive.domain.repository.SMSMessageRepository
import javax.inject.Inject

class SMSMessageRepositoryImpl @Inject constructor(
private val smsMessageService: SMSMessageService
) : SMSMessageRepository {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.droidblossom.archive.data.source.remote.api

interface SMSMessageService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.droidblossom.archive.domain.model

data class SMSMessage(
val content : String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.droidblossom.archive.domain.repository

interface SMSMessageRepository {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.droidblossom.archive.domain.usecase

import javax.inject.Inject

class SMSMessageUseCase @Inject constructor(
private val smsMessageUseCase: SMSMessageUseCase
){
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.droidblossom.di

import com.droidblossom.archive.data.repository.SMSMessageRepositoryImpl
import com.droidblossom.archive.data.source.remote.api.SMSMessageService
import com.droidblossom.archive.domain.repository.SMSMessageRepository
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped

@Module
@InstallIn(ViewModelComponent::class)
object RepositoryModule {

@Provides
@ViewModelScoped
fun providesSMSMessageRepository(
smsMessageService: SMSMessageService
) : SMSMessageRepository = SMSMessageRepositoryImpl(smsMessageService)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.droidblossom.di

import com.google.gson.GsonBuilder
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit
import javax.inject.Singleton

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

@Provides
@Singleton
fun providesConverterFactory() : GsonConverterFactory{
return GsonConverterFactory.create(
GsonBuilder()
.create()
)
}

@Singleton
@Provides
fun providesOkHttpClient() : OkHttpClient.Builder{
return OkHttpClient.Builder().apply {
connectTimeout(5, TimeUnit.SECONDS)
readTimeout(5, TimeUnit.SECONDS)
writeTimeout(5, TimeUnit.SECONDS)
addInterceptor(HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
})
}
}

//TODO baseurl ignore 시켜야함
/*
@Provides
@Singleton
fun providesRetrofit(
client : OkHttpClient.Builder,
gsonConverterFactory: GsonConverterFactory
) : Retrofit {
return Retrofit.Builder()
.baseUrl("")
.addConverterFactory(gsonConverterFactory)
.client(client.build())
.build()
}
*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.droidblossom.di

import com.droidblossom.archive.data.source.remote.api.SMSMessageService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import javax.inject.Singleton

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

@Singleton
@Provides
fun providesSMSMessageService(retrofit: Retrofit) : SMSMessageService = retrofit.create(SMSMessageService::class.java)
}

0 comments on commit 5e2f37e

Please sign in to comment.