-
Notifications
You must be signed in to change notification settings - Fork 0
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
[BASE] #22 Hilt 모듈 구현 #24
Merged
Merged
Changes from 18 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
bed285a
[chore] hilt 의존성 추가
jiwon2724 0c89695
[feature] PokitApplication 구현 및 등록
jiwon2724 1a3478a
[feature] NetworkModule 모듈 구현
jiwon2724 382ab51
[chore] 타임아웃 설정
jiwon2724 ac5257f
[chore] auth request, response 데이터 추가
jiwon2724 3bcbe7f
[chore] auth api 추가
jiwon2724 a0497b0
[chore] auth api 수정
jiwon2724 8b6f46b
[chore] 버전 카탈로그 라이브러리 추가
jiwon2724 138387d
[feature] hilt + 네트워크 모듈 구현
jiwon2724 7b42aa3
[chore] @AndroidEntryPoint 애노테이션 추가
jiwon2724 9d17701
[chore] kotest 의존성 추가
jiwon2724 ea0bec5
[feature] sns로그인 api연동
jiwon2724 a50542f
[feature] 테스트 토큰 인터셉터 구현
jiwon2724 9fb589a
[feature] 닉네임 입력 화면 설계
jiwon2724 5e22432
[chore] 뷰모델 주입
jiwon2724 19a5db3
[chore] 미사용 리소스 제거
jiwon2724 1200e22
[chore] 코딩 컨벤션 적용
jiwon2724 b3a75f5
[chore] 코딩 컨벤션 적용
jiwon2724 a5df3fc
[chore] orbit 제거
jiwon2724 ac83ccb
[chore] LoginScreen 로직 수정
jiwon2724 8280746
[feature] 애플 로그인 구현
jiwon2724 c9ed23f
[feature] 네트워크 통신 모듈 구현
jiwon2724 cc02cbd
[chore] 클래스명 수정
jiwon2724 d8268a5
[chore] 주석 제거
jiwon2724 85d2dc1
[feature] parseErrorResult 함수 구현
jiwon2724 d6b5f7d
[chore] 닉네임 중복 처리 api 세팅
jiwon2724 fdc5cfd
[chore] parseErrorResult 분리 및 적용
jiwon2724 08e9e01
[chore] 중복 닉네임 api 세팅
jiwon2724 7314212
[chore] 코딩 컨벤션 반영
jiwon2724 a61417a
[chore] ktlint rule 추가
jiwon2724 264bf21
Merge branch 'develop' into base/#22-hilt-module
jiwon2724 b77b18a
[chore] ktlint_standard_function-name 제거
jiwon2724 54e8946
[chore] 파일 이름 수정
jiwon2724 a15a33b
Merge remote-tracking branch 'origin/base/#22-hilt-module' into base/…
jiwon2724 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package pokitmons.pokit | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class PokitApplication : Application() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package pokitmons.pokit.data.api | ||
|
||
import pokitmons.pokit.data.model.auth.request.SNSLoginRequest | ||
import pokitmons.pokit.data.model.auth.response.SNSLoginResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
interface AuthApi { | ||
@POST("auth/signin") | ||
suspend fun snsLogin( | ||
@Body snsLoginRequest: SNSLoginRequest, | ||
): SNSLoginResponse | ||
} |
10 changes: 10 additions & 0 deletions
10
data/src/main/java/pokitmons/pokit/data/datasource/remote/auth/AuthDataSource.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,10 @@ | ||
package pokitmons.pokit.data.datasource.remote.auth | ||
|
||
import pokitmons.pokit.data.model.auth.request.SNSLoginRequest | ||
import pokitmons.pokit.data.model.auth.response.SNSLoginResponse | ||
|
||
interface AuthDataSource { | ||
// suspend fun signUp(signUpRequest: SignUpRequest): PokitResponse<SignUpResponse> | ||
suspend fun snsLogin(snsLoginRequest: SNSLoginRequest): SNSLoginResponse | ||
// suspend fun checkDuplicateNickname(nickname: String): PokitResponse<DuplicateNicknameResponse> | ||
} |
12 changes: 12 additions & 0 deletions
12
data/src/main/java/pokitmons/pokit/data/datasource/remote/auth/RemoteAuthDataSourceImpl.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,12 @@ | ||
package pokitmons.pokit.data.datasource.remote.auth | ||
|
||
import pokitmons.pokit.data.api.AuthApi | ||
import pokitmons.pokit.data.model.auth.request.SNSLoginRequest | ||
import pokitmons.pokit.data.model.auth.response.SNSLoginResponse | ||
import javax.inject.Inject | ||
|
||
class RemoteAuthDataSourceImpl @Inject constructor(private val authApi: AuthApi) : AuthDataSource { | ||
override suspend fun snsLogin(snsLoginRequest: SNSLoginRequest): SNSLoginResponse { | ||
return authApi.snsLogin(snsLoginRequest) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
data/src/main/java/pokitmons/pokit/data/di/auth/AuthModule.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,23 @@ | ||
package pokitmons.pokit.data.di.auth | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import pokitmons.pokit.data.datasource.remote.auth.AuthDataSource | ||
import pokitmons.pokit.data.datasource.remote.auth.RemoteAuthDataSourceImpl | ||
import pokitmons.pokit.data.repository.auth.AuthRepositoryImpl | ||
import pokitmons.pokit.domain.repository.auth.AuthRepository | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class AuthModule { | ||
@Binds | ||
@Singleton | ||
abstract fun bindAuthRepository(authRepositoryImpl: AuthRepositoryImpl): AuthRepository | ||
|
||
@Binds | ||
@Singleton | ||
abstract fun bindAuthDataSource(authDataSourceImpl: RemoteAuthDataSourceImpl): AuthDataSource | ||
} |
23 changes: 23 additions & 0 deletions
23
data/src/main/java/pokitmons/pokit/data/di/network/BearerTokenInterceptor.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,23 @@ | ||
package pokitmons.pokit.data.di.network | ||
|
||
import okhttp3.Interceptor | ||
import okhttp3.Request | ||
import okhttp3.Response | ||
import java.io.IOException | ||
|
||
// 토큰 api 수정될 때 까지 사용 | ||
class BearerTokenInterceptor : Interceptor { | ||
@Throws(IOException::class) | ||
override fun intercept(chain: Interceptor.Chain): Response { | ||
val originalRequest: Request = chain.request() | ||
val requestWithToken: Request = originalRequest.newBuilder() | ||
.header( | ||
"Authorization", | ||
"Bearer eyJhbGciOiJIUzM4NCJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzIxNjU4MjUxLCJleHAiOj" + | ||
"MwMDE3MjE2NTgyNTF9.gw6LZimKLuZJ2y0UV5cgvk3F7o92pkRIDgx-qlD_S7qEI01QAFt9dZDyHADabftI" | ||
) | ||
.build() | ||
|
||
return chain.proceed(requestWithToken) | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
data/src/main/java/pokitmons/pokit/data/di/network/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,70 @@ | ||
package pokitmons.pokit.data.di.network | ||
|
||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import pokitmons.pokit.data.api.AuthApi | ||
import retrofit2.Retrofit | ||
import java.util.concurrent.TimeUnit | ||
import javax.inject.Singleton | ||
|
||
private const val BASE_URL = "https://pokit.site" | ||
private const val API = "api" | ||
private const val VERSION = "v1" | ||
|
||
private const val READ_TIME_OUT = 20000L | ||
private const val WRITE_TIME_OUT = 20000L | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object NetworkModule { | ||
@Singleton | ||
@Provides | ||
fun provideOkHttpClient(): OkHttpClient { | ||
return OkHttpClient.Builder() | ||
.addInterceptor(BearerTokenInterceptor()) | ||
.addInterceptor( | ||
HttpLoggingInterceptor().apply { | ||
level = HttpLoggingInterceptor.Level.BODY | ||
} | ||
) | ||
.readTimeout(READ_TIME_OUT, TimeUnit.SECONDS) | ||
.writeTimeout(WRITE_TIME_OUT, TimeUnit.SECONDS) | ||
.build() | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun provideJson(): Json { | ||
return Json { | ||
ignoreUnknownKeys = true | ||
coerceInputValues = true | ||
prettyPrint = true | ||
} | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun provideRetrofit( | ||
okHttpClient: OkHttpClient, | ||
json: Json, | ||
): Retrofit { | ||
val converterFactory = json.asConverterFactory("application/json; charset=UTF8".toMediaType()) | ||
return Retrofit.Builder() | ||
.baseUrl("$BASE_URL/$API/$VERSION/") | ||
.addConverterFactory(converterFactory) | ||
.client(okHttpClient) | ||
.build() | ||
} | ||
|
||
@Provides | ||
fun provideAuthService(retrofit: Retrofit): AuthApi { | ||
return retrofit.create(AuthApi::class.java) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
data/src/main/java/pokitmons/pokit/data/mapper/auth/AuthMapper.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,13 @@ | ||
package pokitmons.pokit.data.mapper.auth | ||
|
||
import pokitmons.pokit.data.model.auth.response.SNSLoginResponse | ||
import pokitmons.pokit.domain.model.auth.SNSLogin | ||
|
||
object AuthMapper { | ||
fun mapperToSNSLogin(snsLoginResponse: SNSLoginResponse): SNSLogin { | ||
return SNSLogin( | ||
accessToken = snsLoginResponse.accessToken, | ||
refreshToken = snsLoginResponse.refreshToken | ||
) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
data/src/main/java/pokitmons/pokit/data/model/auth/request/SNSLoginRequest.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 pokitmons.pokit.data.model.auth.request | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SNSLoginRequest( | ||
val authPlatform: String, | ||
val idToken: String, | ||
) |
6 changes: 6 additions & 0 deletions
6
data/src/main/java/pokitmons/pokit/data/model/auth/request/SignUpRequest.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,6 @@ | ||
package pokitmons.pokit.data.model.auth.request | ||
|
||
data class SignUpRequest( | ||
val nickname: String, | ||
val interests: List<String>, | ||
) |
8 changes: 8 additions & 0 deletions
8
data/src/main/java/pokitmons/pokit/data/model/auth/response/DuplicateNicknameResponse.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,8 @@ | ||
package pokitmons.pokit.data.model.auth.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class DuplicateNicknameResponse( | ||
val isDuplicate: Boolean, | ||
) |
9 changes: 9 additions & 0 deletions
9
data/src/main/java/pokitmons/pokit/data/model/auth/response/SNSLoginResponse.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 pokitmons.pokit.data.model.auth.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SNSLoginResponse( | ||
val accessToken: String, | ||
val refreshToken: String, | ||
) |
5 changes: 5 additions & 0 deletions
5
data/src/main/java/pokitmons/pokit/data/model/auth/response/SignUpResponse.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,5 @@ | ||
package pokitmons.pokit.data.model.auth.response | ||
|
||
data class SignUpResponse( | ||
val userId: Int, | ||
) |
10 changes: 10 additions & 0 deletions
10
data/src/main/java/pokitmons/pokit/data/model/common/PokitResponse.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,10 @@ | ||
package pokitmons.pokit.data.model.common | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class PokitResponse<T>( | ||
val data: T, | ||
val message: String, | ||
val code: String, | ||
) | ||
25 changes: 25 additions & 0 deletions
25
data/src/main/java/pokitmons/pokit/data/repository/auth/AuthRepositoryImpl.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,25 @@ | ||
package pokitmons.pokit.data.repository.auth | ||
|
||
import pokitmons.pokit.data.datasource.remote.auth.AuthDataSource | ||
import pokitmons.pokit.data.mapper.auth.AuthMapper | ||
import pokitmons.pokit.data.model.auth.request.SNSLoginRequest | ||
import pokitmons.pokit.domain.model.auth.SNSLogin | ||
import pokitmons.pokit.domain.repository.auth.AuthRepository | ||
import javax.inject.Inject | ||
|
||
class AuthRepositoryImpl @Inject constructor( | ||
private val remoteAuthDataSource: AuthDataSource, | ||
) : AuthRepository { | ||
override suspend fun snsLogin( | ||
authPlatform: String, | ||
idToken: String, | ||
): Result<SNSLogin> = runCatching { | ||
val snsLoginRequest = SNSLoginRequest(authPlatform = authPlatform, idToken = idToken) | ||
val snsLoginResponse = remoteAuthDataSource.snsLogin(snsLoginRequest) | ||
AuthMapper.mapperToSNSLogin(snsLoginResponse) | ||
}.onFailure { throwable -> | ||
try { | ||
} catch (e: Exception) { | ||
} | ||
} | ||
} |
16 changes: 0 additions & 16 deletions
16
data/src/test/java/pokitmons/pokit/data/ExampleUnitTest.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
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
domain/src/main/java/pokitmons/pokit/domain/model/auth/SNSLogin.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,6 @@ | ||
package pokitmons.pokit.domain.model.auth | ||
|
||
data class SNSLogin( | ||
val accessToken: String, | ||
val refreshToken: String, | ||
) |
10 changes: 10 additions & 0 deletions
10
domain/src/main/java/pokitmons/pokit/domain/repository/auth/AuthRepository.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,10 @@ | ||
package pokitmons.pokit.domain.repository.auth | ||
|
||
import pokitmons.pokit.domain.model.auth.SNSLogin | ||
|
||
interface AuthRepository { | ||
suspend fun snsLogin( | ||
authPlatform: String, | ||
idToken: String, | ||
): Result<SNSLogin> | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
회의때 잠깐 구현했던 코드 혹시 몰라서 첨부합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
짱짱~~!