-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT/#72] ์์ ๋ก๊ทธ์ธ / ์๋ฒํต์ ๋ก์ง ๊ตฌํ
- Loading branch information
Showing
33 changed files
with
302 additions
and
147 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.terning.point.di | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import com.terning.data.local.TerningDataStore | ||
import com.terning.data.local.TerningDataStoreImpl | ||
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 provideTerningDataStore(dataStoreImpl: TerningDataStoreImpl): TerningDataStore = | ||
dataStoreImpl | ||
} |
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
12 changes: 12 additions & 0 deletions
12
data/src/main/java/com/terning/data/datasource/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,12 @@ | ||
package com.terning.data.datasource | ||
|
||
import com.terning.data.dto.BaseResponse | ||
import com.terning.data.dto.request.SignInRequestDto | ||
import com.terning.data.dto.response.SignInResponseDto | ||
|
||
interface AuthDataSource { | ||
suspend fun postSignIn( | ||
authorization: String, | ||
platform: SignInRequestDto | ||
): BaseResponse<SignInResponseDto> | ||
} |
7 changes: 0 additions & 7 deletions
7
data/src/main/java/com/terning/data/datasource/MockDataSource.kt
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
data/src/main/java/com/terning/data/datasourceimpl/AuthDataSourceImpl.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,17 @@ | ||
package com.terning.data.datasourceimpl | ||
|
||
import com.terning.data.datasource.AuthDataSource | ||
import com.terning.data.dto.BaseResponse | ||
import com.terning.data.dto.request.SignInRequestDto | ||
import com.terning.data.dto.response.SignInResponseDto | ||
import com.terning.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<SignInResponseDto> = authService.postSignIn(authorization, platform) | ||
} |
13 changes: 0 additions & 13 deletions
13
data/src/main/java/com/terning/data/datasourceimpl/MockDataSourceImpl.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
14 changes: 14 additions & 0 deletions
14
data/src/main/java/com/terning/data/dto/request/SignInRequestDto.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,14 @@ | ||
package com.terning.data.dto.request | ||
|
||
import com.terning.domain.entity.request.SignInRequestModel | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SignInRequestDto( | ||
@SerialName("authType") | ||
val authType: String | ||
) | ||
|
||
fun SignInRequestModel.toSignInRequestDto(): SignInRequestDto = | ||
SignInRequestDto(authType = authType) |
53 changes: 0 additions & 53 deletions
53
data/src/main/java/com/terning/data/dto/response/MockResponseDto.kt
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
data/src/main/java/com/terning/data/dto/response/SignInResponseDto.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,24 @@ | ||
package com.terning.data.dto.response | ||
|
||
import com.terning.domain.entity.response.SignInResponseModel | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SignInResponseDto( | ||
@SerialName("accessToken") | ||
val accessToken: String, | ||
@SerialName("refreshToken") | ||
val refreshToken: String, | ||
@SerialName("userId") | ||
val userId: Long, | ||
@SerialName("authType") | ||
val authType: String, | ||
) { | ||
fun toSignInModel() = SignInResponseModel( | ||
accessToken = accessToken, | ||
refreshToken = refreshToken, | ||
userId = userId, | ||
authType = authType | ||
) | ||
} |
8 changes: 8 additions & 0 deletions
8
data/src/main/java/com/terning/data/local/TerningDataStore.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 com.terning.data.local | ||
|
||
interface TerningDataStore { | ||
var accessToken: String | ||
var refreshToken: String | ||
var userId: Long | ||
fun clearInfo() | ||
} |
31 changes: 31 additions & 0 deletions
31
data/src/main/java/com/terning/data/local/TerningDataStoreImpl.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,31 @@ | ||
package com.terning.data.local | ||
|
||
import android.content.SharedPreferences | ||
import androidx.core.content.edit | ||
import javax.inject.Inject | ||
|
||
class TerningDataStoreImpl @Inject constructor( | ||
private val dataStore: SharedPreferences, | ||
) : TerningDataStore { | ||
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) } | ||
|
||
override var userId: Long | ||
get() = dataStore.getLong(USER_ID, 0L) | ||
set(value) = dataStore.edit { putLong(USER_ID, value) } | ||
|
||
override fun clearInfo() { | ||
dataStore.edit().clear().commit() | ||
} | ||
|
||
companion object { | ||
private const val ACCESS_TOKEN = "ACCESS_TOKEN" | ||
private const val REFRESH_TOKEN = "REFRESH_TOKEN" | ||
private const val USER_ID = "USER_ID" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
data/src/main/java/com/terning/data/repositoryimpl/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,22 @@ | ||
package com.terning.data.repositoryimpl | ||
|
||
import com.terning.data.datasource.AuthDataSource | ||
import com.terning.data.dto.request.toSignInRequestDto | ||
import com.terning.domain.entity.request.SignInRequestModel | ||
import com.terning.domain.entity.response.SignInResponseModel | ||
import com.terning.domain.repository.AuthRepository | ||
import javax.inject.Inject | ||
|
||
class AuthRepositoryImpl @Inject constructor( | ||
private val authDataSource: AuthDataSource | ||
) : AuthRepository { | ||
override suspend fun postSignIn( | ||
authorization: String, | ||
request: SignInRequestModel | ||
): Result<SignInResponseModel> = kotlin.runCatching { | ||
authDataSource.postSignIn( | ||
authorization, | ||
request.toSignInRequestDto() | ||
).result.toSignInModel() | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
data/src/main/java/com/terning/data/repositoryimpl/MockRepositoryImpl.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.