diff --git a/data/src/main/java/com/yapp/data/datasource/SessionRemoteDataSource.kt b/data/src/main/java/com/yapp/data/datasource/SessionRemoteDataSource.kt index a5a414c3..63dd6ce1 100644 --- a/data/src/main/java/com/yapp/data/datasource/SessionRemoteDataSource.kt +++ b/data/src/main/java/com/yapp/data/datasource/SessionRemoteDataSource.kt @@ -4,6 +4,6 @@ import com.yapp.data.model.SessionEntity interface SessionRemoteDataSource { suspend fun setSession(session: SessionEntity) - suspend fun getSession(id: Long): SessionEntity? + suspend fun getSession(id: Int): SessionEntity? suspend fun getAllSession(): List } diff --git a/data/src/main/java/com/yapp/data/datasource/SessionRemoteDataSourceImpl.kt b/data/src/main/java/com/yapp/data/datasource/SessionRemoteDataSourceImpl.kt index 8c31de19..a06d1c8e 100644 --- a/data/src/main/java/com/yapp/data/datasource/SessionRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/yapp/data/datasource/SessionRemoteDataSourceImpl.kt @@ -26,7 +26,7 @@ class SessionRemoteDataSourceImpl @Inject constructor( } } - override suspend fun getSession(id: Long): SessionEntity? { + override suspend fun getSession(id: Int): SessionEntity? { return suspendCancellableCoroutine { cancellableContinuation -> fireStore.sessionRef() .document(id.toString()) diff --git a/data/src/main/java/com/yapp/data/repository/SessionRepositoryImpl.kt b/data/src/main/java/com/yapp/data/repository/SessionRepositoryImpl.kt index 27502eed..668b0456 100644 --- a/data/src/main/java/com/yapp/data/repository/SessionRepositoryImpl.kt +++ b/data/src/main/java/com/yapp/data/repository/SessionRepositoryImpl.kt @@ -25,7 +25,7 @@ class SessionRepositoryImpl @Inject constructor( ) } - override suspend fun getSession(id: Long): Result { + override suspend fun getSession(id: Int): Result { return runCatching { sessionRemoteDataSource.getSession(id)?.toDomain(dateParser) }.fold( diff --git a/domain/src/main/java/com/yapp/domain/repository/SessionRepository.kt b/domain/src/main/java/com/yapp/domain/repository/SessionRepository.kt index b44c6ceb..4156742d 100644 --- a/domain/src/main/java/com/yapp/domain/repository/SessionRepository.kt +++ b/domain/src/main/java/com/yapp/domain/repository/SessionRepository.kt @@ -4,6 +4,6 @@ import com.yapp.domain.model.Session interface SessionRepository { suspend fun setSession(session: Session): Result - suspend fun getSession(id: Long): Result + suspend fun getSession(id: Int): Result suspend fun getAllSession(): Result> } diff --git a/domain/src/main/java/com/yapp/domain/usecases/CheckSessionPasswordUseCase.kt b/domain/src/main/java/com/yapp/domain/usecases/CheckSessionPasswordUseCase.kt index 49fe4cbe..50ba423c 100644 --- a/domain/src/main/java/com/yapp/domain/usecases/CheckSessionPasswordUseCase.kt +++ b/domain/src/main/java/com/yapp/domain/usecases/CheckSessionPasswordUseCase.kt @@ -1,14 +1,16 @@ package com.yapp.domain.usecases -import com.yapp.domain.repository.RemoteConfigRepository +import com.yapp.domain.repository.SessionRepository import javax.inject.Inject class CheckSessionPasswordUseCase @Inject constructor( - private val remoteConfigRepository: RemoteConfigRepository, + private val sessionRepository: SessionRepository ) { - suspend operator fun invoke(inputPassword: String): Result { - return remoteConfigRepository.getSessionPassword().mapCatching { sessionPassword: String -> - inputPassword == sessionPassword + suspend operator fun invoke(sessionId: Int, inputPassword: String): Result { + return sessionRepository.getSession(id = sessionId).mapCatching { session -> + check(session != null) { "${sessionId}에 해당하는 Session이 존재하지 않습니다" } + + inputPassword == session.code } } } \ No newline at end of file diff --git a/presentation/src/main/java/com/yapp/presentation/ui/member/signup/password/PassWordViewModel.kt b/presentation/src/main/java/com/yapp/presentation/ui/member/signup/password/PassWordViewModel.kt index 54c6fc13..47b70706 100644 --- a/presentation/src/main/java/com/yapp/presentation/ui/member/signup/password/PassWordViewModel.kt +++ b/presentation/src/main/java/com/yapp/presentation/ui/member/signup/password/PassWordViewModel.kt @@ -5,6 +5,7 @@ import com.google.firebase.FirebaseNetworkException import com.yapp.common.base.BaseViewModel import com.yapp.domain.usecases.CheckSessionPasswordUseCase import com.yapp.domain.usecases.CheckSignUpPasswordUseCase +import com.yapp.presentation.common.AttendanceBundle import com.yapp.presentation.ui.member.signup.password.PasswordContract.PasswordSideEffect import com.yapp.presentation.ui.member.signup.password.PasswordContract.PasswordUiEvent import com.yapp.presentation.ui.member.signup.password.PasswordContract.PasswordUiState @@ -70,7 +71,11 @@ internal class PassWordViewModel @Inject constructor( private fun checkSessionPassword(password: String) = viewModelScope.launch { setEffect(PasswordSideEffect.KeyboardHide) - checkSessionPasswordUseCase(password) + + // TODO AttendanceBundle을 사용하지 않고 Navagation의 Argument로 넘어온 Id를 사용하도록 수정할것 + val sessionId = AttendanceBundle.upComingSession!!.sessionId + + checkSessionPasswordUseCase(sessionId = sessionId, inputPassword = password) .onSuccess { isPasswordValid -> when (isPasswordValid) { true -> { @@ -91,5 +96,5 @@ internal class PassWordViewModel @Inject constructor( } } } - + }