-
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
1 parent
12147ff
commit 4374fa7
Showing
7 changed files
with
57 additions
and
19 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
data/src/main/kotlin/com/bff/wespot/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,24 @@ | ||
package com.bff.wespot.data.repository.auth | ||
|
||
import com.bff.wespot.data.mapper.auth.toDto | ||
import com.bff.wespot.domain.repository.auth.AuthRepository | ||
import com.bff.wespot.model.auth.request.KakaoAuthToken | ||
import com.bff.wespot.model.auth.response.AuthToken | ||
import com.bff.wespot.model.auth.response.School | ||
import com.bff.wespot.network.model.auth.response.SchoolDto | ||
import com.bff.wespot.network.source.auth.AuthDataSource | ||
import javax.inject.Inject | ||
|
||
class AuthRepositoryImpl @Inject constructor( | ||
private val authDataSource: AuthDataSource | ||
) : AuthRepository { | ||
override suspend fun getSchoolList(search: String): Result<List<School>> = | ||
authDataSource | ||
.getSchoolList(search) | ||
.map { it.schools.map(SchoolDto::toSchool) } | ||
|
||
override suspend fun sendKakaoToken(token: KakaoAuthToken): Result<AuthToken> = | ||
authDataSource | ||
.sendKakaoToken(token.toDto()) | ||
.map { it.toAuthToken() } | ||
} |
17 changes: 0 additions & 17 deletions
17
data/src/main/kotlin/com/bff/wespot/data/repository/message/AuthRepositoryImpl.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
10 changes: 10 additions & 0 deletions
10
domain/src/main/kotlin/com/bff/wespot/domain/repository/DataStoreRepository.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 com.bff.wespot.domain.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface DataStoreRepository { | ||
suspend fun saveString(key: String, value: String) | ||
fun getString(key: String): Flow<String> | ||
suspend fun saveBoolean(key: String, value: Boolean) | ||
fun getBoolean(key: String): Flow<Boolean> | ||
} |
16 changes: 14 additions & 2 deletions
16
domain/src/main/kotlin/com/bff/wespot/domain/usecase/KakaoLoginUseCase.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,14 +1,26 @@ | ||
package com.bff.wespot.domain.usecase | ||
|
||
import com.bff.wespot.domain.repository.DataStoreRepository | ||
import com.bff.wespot.domain.repository.auth.AuthRepository | ||
import com.bff.wespot.domain.repository.auth.KakaoLoginManager | ||
import com.bff.wespot.domain.util.DataStoreKey | ||
import javax.inject.Inject | ||
import javax.xml.crypto.Data | ||
|
||
class KakaoLoginUseCase @Inject constructor( | ||
val kakaoLoginManager: KakaoLoginManager, | ||
val authRepository: AuthRepository, | ||
val dataStoreRepository: DataStoreRepository | ||
) { | ||
// 나중에 authrepository랑 연결될 예정 | ||
suspend inline fun invoke() { | ||
val result = kakaoLoginManager.loginWithKakao() | ||
println("token $result") | ||
authRepository.sendKakaoToken(result) | ||
.onSuccess { | ||
dataStoreRepository.saveString(DataStoreKey.ACCESS_TOKEN, it.accessToken) | ||
dataStoreRepository.saveString(DataStoreKey.REFRESH_TOKEN, it.refreshToken) | ||
} | ||
.onFailure { | ||
throw(it) | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
domain/src/main/kotlin/com/bff/wespot/domain/util/DataStoreKey.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 com.bff.wespot.domain.util | ||
|
||
object DataStoreKey { | ||
const val ACCESS_TOKEN = "access_token" | ||
const val REFRESH_TOKEN = "refresh_token" | ||
} |
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