-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
215 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...ardener/app/src/main/java/team/gdsc/earthgardener/data/datasource/CheckEmailDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
package team.gdsc.earthgardener.data.datasource | ||
|
||
import team.gdsc.earthgardener.data.model.request.ReqCheckEmailSuccessData | ||
import team.gdsc.earthgardener.data.model.response.ResCheckEmailSuccessData | ||
|
||
interface CheckEmailDataSource { | ||
suspend fun getCheckEmail(body: ReqCheckEmailSuccessData): ResCheckEmailSuccessData | ||
suspend fun getCheckEmail(email: String): ResCheckEmailSuccessData | ||
} |
5 changes: 2 additions & 3 deletions
5
...r/app/src/main/java/team/gdsc/earthgardener/data/datasource/CheckEmailRemoteDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package team.gdsc.earthgardener.data.datasource | ||
|
||
import team.gdsc.earthgardener.data.api.LoginService | ||
import team.gdsc.earthgardener.data.model.request.ReqCheckEmailSuccessData | ||
import team.gdsc.earthgardener.data.model.response.ResCheckEmailSuccessData | ||
|
||
class CheckEmailRemoteDataSource (private val loginService: LoginService) : CheckEmailDataSource { | ||
override suspend fun getCheckEmail(body: ReqCheckEmailSuccessData): ResCheckEmailSuccessData { | ||
return loginService.GetEmail(body) | ||
override suspend fun getCheckEmail(email: String): ResCheckEmailSuccessData { | ||
return loginService.GetEmail(email) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
.../app/src/main/java/team/gdsc/earthgardener/data/model/request/ReqCheckEmailSuccessData.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
EarthGardener/app/src/main/java/team/gdsc/earthgardener/di/DataSourceModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package team.gdsc.earthgardener.di | ||
|
||
import org.koin.dsl.module | ||
import team.gdsc.earthgardener.data.datasource.CheckEmailDataSource | ||
import team.gdsc.earthgardener.data.datasource.CheckEmailRemoteDataSource | ||
|
||
val dataSourceModule = module{ | ||
single<CheckEmailDataSource>{CheckEmailRemoteDataSource(get())} | ||
} |
29 changes: 29 additions & 0 deletions
29
EarthGardener/app/src/main/java/team/gdsc/earthgardener/di/EarthGardenerApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package team.gdsc.earthgardener.di | ||
|
||
import android.app.Application | ||
import android.content.SharedPreferences | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.core.context.startKoin | ||
|
||
class EarthGardenerApplication: Application() { | ||
|
||
companion object{ | ||
lateinit var sSharedPreferences: SharedPreferences | ||
lateinit var editor: SharedPreferences.Editor | ||
|
||
val X_ACCESS_TOKEN = "X-ACCESS-TOKEN" | ||
} | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
sSharedPreferences = applicationContext.getSharedPreferences("EARTH_GARDENER", MODE_PRIVATE) | ||
editor = sSharedPreferences.edit() | ||
|
||
startKoin{ | ||
androidContext(this@EarthGardenerApplication) | ||
modules(netWorkModule, dataSourceModule, repositoryModule, viewModelModule) | ||
} | ||
|
||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
EarthGardener/app/src/main/java/team/gdsc/earthgardener/di/NetworkModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package team.gdsc.earthgardener.di | ||
|
||
import com.google.gson.GsonBuilder | ||
import okhttp3.Interceptor | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import org.koin.dsl.module | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
import team.gdsc.earthgardener.data.api.LoginService | ||
import team.gdsc.earthgardener.di.EarthGardenerApplication.Companion.X_ACCESS_TOKEN | ||
import team.gdsc.earthgardener.di.EarthGardenerApplication.Companion.sSharedPreferences | ||
|
||
val netWorkModule = module { | ||
single{ | ||
OkHttpClient.Builder() | ||
.addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) | ||
.addNetworkInterceptor(XAccessTokenInterceptor()) | ||
.addInterceptor(Interceptor { chain -> | ||
chain.proceed( | ||
chain.request().newBuilder() | ||
.build() | ||
) | ||
}) | ||
.build() | ||
} | ||
|
||
single<Retrofit>{ | ||
Retrofit.Builder() | ||
.client(get()) | ||
.addConverterFactory(GsonConverterFactory.create(GsonBuilder().setLenient().create())) | ||
.baseUrl("http://52.78.175.39:8080/") | ||
.build() | ||
} | ||
|
||
single<LoginService>{ | ||
get<Retrofit>().create(LoginService::class.java) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
EarthGardener/app/src/main/java/team/gdsc/earthgardener/di/RepositoryModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package team.gdsc.earthgardener.di | ||
|
||
import org.koin.dsl.module | ||
import team.gdsc.earthgardener.data.repository.CheckEmailRepositoryImpl | ||
import team.gdsc.earthgardener.domain.LoginRepository | ||
|
||
val repositoryModule = module{ | ||
single<LoginRepository>{CheckEmailRepositoryImpl(get())} | ||
} |
9 changes: 9 additions & 0 deletions
9
EarthGardener/app/src/main/java/team/gdsc/earthgardener/di/ViewModelModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package team.gdsc.earthgardener.di | ||
|
||
import org.koin.androidx.viewmodel.dsl.viewModel | ||
import org.koin.dsl.module | ||
import team.gdsc.earthgardener.presentation.user.signup.viewModel.CheckEmailViewModel | ||
|
||
val viewModelModule = module{ | ||
viewModel{CheckEmailViewModel(get())} | ||
} |
19 changes: 19 additions & 0 deletions
19
EarthGardener/app/src/main/java/team/gdsc/earthgardener/di/XAccessTokenInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package team.gdsc.earthgardener.di | ||
|
||
import okhttp3.Interceptor | ||
import okhttp3.Request | ||
import okhttp3.Response | ||
import team.gdsc.earthgardener.di.EarthGardenerApplication.Companion.X_ACCESS_TOKEN | ||
import team.gdsc.earthgardener.di.EarthGardenerApplication.Companion.sSharedPreferences | ||
|
||
class XAccessTokenInterceptor: Interceptor { | ||
|
||
override fun intercept(chain: Interceptor.Chain): Response { | ||
val builder: Request.Builder = chain.request().newBuilder() | ||
val jwtToken: String? = sSharedPreferences.getString(X_ACCESS_TOKEN, null) | ||
if(jwtToken != null){ | ||
builder.addHeader("X-ACCESS-TOKEN", jwtToken) | ||
} | ||
return chain.proceed(builder.build()) | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
EarthGardener/app/src/main/java/team/gdsc/earthgardener/domain/CheckEmailData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package team.gdsc.earthgardener.domain | ||
|
||
data class CheckEmailData( | ||
val code: String | ||
val code: String, | ||
val message: String, | ||
val status: Int | ||
) |
5 changes: 1 addition & 4 deletions
5
EarthGardener/app/src/main/java/team/gdsc/earthgardener/domain/LoginRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
package team.gdsc.earthgardener.domain | ||
|
||
import team.gdsc.earthgardener.data.model.request.ReqCheckEmailSuccessData | ||
import team.gdsc.earthgardener.data.model.response.ResCheckEmailSuccessData | ||
|
||
interface LoginRepository { | ||
suspend fun getCheckEmailResult(body: ReqCheckEmailSuccessData): CheckEmailData | ||
suspend fun getCheckEmailResult(email: String): CheckEmailData | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.