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

[Feat/#41] sharedpreferences + SignIn + SignUp 분기 처리 및 연결 #53

Merged
merged 22 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b7b6367
[CHORE/#41] sharedpreferences 구현
chattymin Jan 8, 2024
f141fd8
[CHORE/#41] sharedpreferences 구현
chattymin Jan 8, 2024
3903dbe
[FIX/#41] app Key 변경 -> kakao login error fix
chattymin Jan 8, 2024
309dffd
Merge branch 'develop' into feat/#41-sharedpreferences
chattymin Jan 8, 2024
3cd3b8e
[FIX/#41] 쉐어드프리퍼런스 구현
chattymin Jan 9, 2024
e65a140
[FIX/#41] kakao login 흐름 구현 -> 회원가입 이동
chattymin Jan 9, 2024
3b0df13
[FIX/#41] error code 상수화
chattymin Jan 9, 2024
d53253b
[FIX/#41] SignUp 기초 flow 세팅
chattymin Jan 9, 2024
4a1af06
[FIX/#41] 서버통신 에러코드 익스텐션 생성 및 적용
chattymin Jan 9, 2024
386b29e
[FIX/#41] 서버통신 에러코드 익스텐션 간략화
chattymin Jan 9, 2024
a1d8787
[FIX/#41] 구조 리펙토링
chattymin Jan 9, 2024
6dae170
[FEAT/#41] SignUp Api 구현
chattymin Jan 9, 2024
17170fc
[FEAT/#41] SignUp Api 구현 및 분기처리
chattymin Jan 9, 2024
fc88ef2
[FEAT/#41] sharedpreferences 기능 연결
chattymin Jan 9, 2024
19b6622
[FEAT/#41] signup 분기처리
chattymin Jan 9, 2024
15919b8
[FEAT/#41] SignIn 분기처리
chattymin Jan 9, 2024
f0152ac
[CHORE/#41] 미사용 import 및 객체 삭제
chattymin Jan 9, 2024
837d0b2
[FEAT/#41] SignIn model 생성 및 적용
chattymin Jan 9, 2024
cb6ebb9
[CHORE/#41] SignIn으로 네이밍 통일
chattymin Jan 9, 2024
a49e3d8
[CHORE/#41] 변수명 수정
chattymin Jan 9, 2024
098cb9c
[CHORE/#41] 줄바꿈
chattymin Jan 9, 2024
a1a2f0e
Merge branch 'develop' into feat/#41-sharedpreferences
chattymin Jan 9, 2024
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
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {
gradleLocalProperties(rootDir).getProperty("native.app.key"),
)
manifestPlaceholders["NATIVE_APP_KEY"] =
gradleLocalProperties(rootDir).getProperty("native.app.key")
gradleLocalProperties(rootDir).getProperty("nativeAppKey")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

후후

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

김상호 그는 신이야!!! 김상호 그는 신이야!!! 김상호 그는 신이야!!! 김상호 그는 신이야!!! 김상호 그는 신이야!!! 김상호 그는 신이야!!! 김상호 그는 신이야!!! 김상호 그는 신이야!!! 김상호 그는 신이야!!! 김상호 그는 신이야!!! 김상호 그는 신이야!!! 김상호 그는 신이야!!!

}

buildTypes {
Expand Down
11 changes: 5 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="oauth"
<!-- Redirect URI: "kakao${NATIVE_APP_KEY}://oauth" -->
<data android:host="oauth"
android:scheme="kakao${NATIVE_APP_KEY}" />
</intent-filter>
</activity>
Expand All @@ -37,7 +36,7 @@
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.splash.SplashActivity"
android:name="com.going.presentation.onboarding.splash.SplashActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
Expand All @@ -48,7 +47,7 @@
</activity>

<activity
android:name="com.going.presentation.auth.SignInActivity"
android:name="com.going.presentation.onboarding.signin.SignInActivity"
android:exported="false"
android:screenOrientation="portrait" />

Expand All @@ -58,7 +57,7 @@
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.onboarding.OnboardingProfileSettingActivity"
android:name="com.going.presentation.onboarding.signup.OnboardingProfileSettingActivity"
android:exported="false"
android:screenOrientation="portrait" />

Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/com/going/going/di/DataSourceModule.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.going.going.di

import com.going.data.datasource.LoginDataSource
import com.going.data.datasource.AuthDataSource
import com.going.data.datasource.MockDataSource
import com.going.data.datasourceImpl.LoginDataSourceImpl
import com.going.data.datasourceImpl.AuthDataSourceImpl
import com.going.data.datasourceImpl.MockDataSourceImpl
import dagger.Module
import dagger.Provides
Expand All @@ -21,8 +21,6 @@ object DataSourceModule {

@Provides
@Singleton
fun provideLoginDataSource(loginDataSourceImpl: LoginDataSourceImpl): LoginDataSource =
loginDataSourceImpl


fun provideAuthDataSource(authDataSourceImpl: AuthDataSourceImpl): AuthDataSource =
authDataSourceImpl
}
27 changes: 27 additions & 0 deletions app/src/main/java/com/going/going/di/DataStoreModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.going.going.di

import android.content.Context
import android.content.SharedPreferences
import com.going.data.local.GoingDataStoreImpl
import com.going.data.local.GoingDataStore
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

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

@Provides
@Singleton
fun provideSharedPreferences(@ApplicationContext context: Context): SharedPreferences =
context.getSharedPreferences(context.packageName, Context.MODE_PRIVATE)

@Provides
@Singleton
fun provideGoingDataStore(dataStoreImpl: GoingDataStoreImpl): GoingDataStore =
dataStoreImpl
}
15 changes: 11 additions & 4 deletions app/src/main/java/com/going/going/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.going.going.di

import com.going.data.repositoryImpl.LoginRepositoryImpl
import com.going.data.repositoryImpl.TokenRepositoryImpl
import com.going.data.repositoryImpl.AuthRepositoryImpl
import com.going.data.repositoryImpl.MockRepositoryImpl
import com.going.domain.repository.LoginRepository
import com.going.domain.repository.TokenRepository
import com.going.domain.repository.AuthRepository
import com.going.domain.repository.MockRepository
import dagger.Module
import dagger.Provides
Expand All @@ -21,6 +23,11 @@ object RepositoryModule {

@Provides
@Singleton
fun provideLoginRepository(loginRepositoryImpl: LoginRepositoryImpl): LoginRepository =
loginRepositoryImpl
fun provideAuthRepository(authRepositoryImpl: AuthRepositoryImpl): AuthRepository =
authRepositoryImpl

@Provides
@Singleton
fun provideTokenRepository(tokenRepositoryImpl: TokenRepositoryImpl): TokenRepository =
tokenRepositoryImpl
}
7 changes: 3 additions & 4 deletions app/src/main/java/com/going/going/di/ServiceModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.going.going.di

import com.going.data.service.LoginService
import com.going.data.service.AuthService
import com.going.data.service.MockService
import dagger.Module
import dagger.Provides
Expand All @@ -20,7 +20,6 @@ object ServiceModule {

@Provides
@Singleton
fun provideLoginService(retrofit: Retrofit): LoginService =
retrofit.create(LoginService::class.java)

fun provideLoginService(retrofit: Retrofit): AuthService =
retrofit.create(AuthService::class.java)
}
2 changes: 1 addition & 1 deletion core-ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ dependencies {
testImplementation(TestDependencies.jUnit)
androidTestImplementation(TestDependencies.androidTest)
androidTestImplementation(TestDependencies.espresso)
}
}
18 changes: 18 additions & 0 deletions data/src/main/java/com/going/data/datasource/AuthDataSource.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.going.data.datasource

import com.going.data.dto.BaseResponse
import com.going.data.dto.request.SignInRequestDto
import com.going.data.dto.request.SignUpRequestDto
import com.going.data.dto.response.AuthResponseDto

interface AuthDataSource {
suspend fun postSignIn(
Authorization: String,
platform: SignInRequestDto,
): BaseResponse<AuthResponseDto>

suspend fun postSignUp(
Authorization: String,
data: SignUpRequestDto,
): BaseResponse<AuthResponseDto>
}
12 changes: 0 additions & 12 deletions data/src/main/java/com/going/data/datasource/LoginDataSource.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.going.data.datasourceImpl

import com.going.data.datasource.AuthDataSource
import com.going.data.dto.BaseResponse
import com.going.data.dto.request.SignInRequestDto
import com.going.data.dto.request.SignUpRequestDto
import com.going.data.dto.response.AuthResponseDto
import com.going.data.service.AuthService
import javax.inject.Inject

class AuthDataSourceImpl @Inject constructor(
private val authService: AuthService,
) : AuthDataSource {
override suspend fun postSignIn(
Authorization: String,
platform: SignInRequestDto,
): BaseResponse<AuthResponseDto> =
authService.postSignin(Authorization, platform)

override suspend fun postSignUp(
Authorization: String,
data: SignUpRequestDto,
): BaseResponse<AuthResponseDto> = authService.postSignUp(Authorization, data)
}

This file was deleted.

10 changes: 0 additions & 10 deletions data/src/main/java/com/going/data/dto/request/RequestLoginDto.kt

This file was deleted.

15 changes: 15 additions & 0 deletions data/src/main/java/com/going/data/dto/request/SignInRequestDto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.going.data.dto.request

import com.going.domain.entity.request.RequestSignInModel
import com.going.domain.entity.request.RequestSignUpModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class SignInRequestDto(
@SerialName("platform")
val platform: String
)

fun RequestSignInModel.toSignInRequestDto(): SignInRequestDto =
SignInRequestDto(platform)
18 changes: 18 additions & 0 deletions data/src/main/java/com/going/data/dto/request/SignUpRequestDto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.going.data.dto.request

import com.going.domain.entity.request.RequestSignUpModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class SignUpRequestDto(
@SerialName("name")
val name: String,
@SerialName("intro")
val intro: String,
@SerialName("platform")
val platform: String,
)

fun RequestSignUpModel.toSignUpRequestDto(): SignUpRequestDto =
SignUpRequestDto(name, intro, platform)
16 changes: 16 additions & 0 deletions data/src/main/java/com/going/data/dto/response/AuthResponseDto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.going.data.dto.response

import com.going.domain.entity.response.AuthTokenModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class AuthResponseDto(
@SerialName("accessToken")
val accessToken: String,
@SerialName("refreshToken")
val refreshToken: String,
) {
fun toAuthTokenModel() =
AuthTokenModel(accessToken = accessToken, refreshToken = refreshToken)
}
37 changes: 0 additions & 37 deletions data/src/main/java/com/going/data/dto/response/LoginResponseDto.kt

This file was deleted.

6 changes: 6 additions & 0 deletions data/src/main/java/com/going/data/local/GoingDataStore.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.going.data.local

interface GoingDataStore {
var accessToken: String
var refreshToken: String
}
22 changes: 22 additions & 0 deletions data/src/main/java/com/going/data/local/GoingDataStoreImpl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.going.data.local

import android.content.SharedPreferences
import androidx.core.content.edit
import javax.inject.Inject

class GoingDataStoreImpl @Inject constructor(
private val dataStore: SharedPreferences,
) : GoingDataStore {
override var accessToken: String
get() = dataStore.getString(ACCESS_TOKEN, "") ?: ""
set(value) = dataStore.edit { putString(ACCESS_TOKEN, value) }

override var refreshToken: String
get() = dataStore.getString(REFRESH_TOKEN, "") ?: ""
set(value) = dataStore.edit { putString(REFRESH_TOKEN, value) }

companion object {
private const val ACCESS_TOKEN = "ACCESS_TOKEN"
private const val REFRESH_TOKEN = "REFRESH_TOKEN"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.going.data.repositoryImpl

import com.going.data.datasource.AuthDataSource
import com.going.data.dto.request.toSignInRequestDto
import com.going.data.dto.request.toSignUpRequestDto
import com.going.domain.entity.request.RequestSignInModel
import com.going.domain.entity.request.RequestSignUpModel
import com.going.domain.entity.response.AuthTokenModel
import com.going.domain.repository.AuthRepository
import javax.inject.Inject

class AuthRepositoryImpl @Inject constructor(
private val authDataSource: AuthDataSource,
) : AuthRepository {
override suspend fun postSignIn(
Authorization: String,
requestSignIpModel: RequestSignInModel,
): Result<AuthTokenModel> =
runCatching {
authDataSource.postSignIn(
Authorization,
requestSignIpModel.toSignInRequestDto(),
).data.toAuthTokenModel()
}

override suspend fun postSignUp(
Authorization: String,
requestSignUpModel: RequestSignUpModel,
): Result<AuthTokenModel> =
runCatching {
authDataSource.postSignUp(
Authorization,
requestSignUpModel.toSignUpRequestDto(),
).data.toAuthTokenModel()
}
}
Loading