Skip to content

Commit

Permalink
출석시 Session 모델에 담긴 Code로 출석하도록 수정
Browse files Browse the repository at this point in the history
- RemoteConfig에 존재하는 공통의 출석코드가 아닌 각 세션에 존재하는 Code를 Input과 비교하여 출석하도록 수정
  • Loading branch information
toastmeister1 committed Jan 20, 2024
1 parent 7ee1f37 commit 9f5c282
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SessionEntity>
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SessionRepositoryImpl @Inject constructor(
)
}

override suspend fun getSession(id: Long): Result<Session?> {
override suspend fun getSession(id: Int): Result<Session?> {
return runCatching {
sessionRemoteDataSource.getSession(id)?.toDomain(dateParser)
}.fold(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import com.yapp.domain.model.Session

interface SessionRepository {
suspend fun setSession(session: Session): Result<Unit>
suspend fun getSession(id: Long): Result<Session?>
suspend fun getSession(id: Int): Result<Session?>
suspend fun getAllSession(): Result<List<Session>>
}
Original file line number Diff line number Diff line change
@@ -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<Boolean> {
return remoteConfigRepository.getSessionPassword().mapCatching { sessionPassword: String ->
inputPassword == sessionPassword
suspend operator fun invoke(sessionId: Int, inputPassword: String): Result<Boolean> {
return sessionRepository.getSession(id = sessionId).mapCatching { session ->
check(session != null) { "${sessionId}에 해당하는 Session이 존재하지 않습니다" }

inputPassword == session.code
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 -> {
Expand All @@ -91,5 +96,5 @@ internal class PassWordViewModel @Inject constructor(
}
}
}

}

0 comments on commit 9f5c282

Please sign in to comment.