Skip to content

Commit

Permalink
[feat/#76] 출석 QR Text api usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnseo committed Feb 7, 2024
1 parent 5181086 commit 5f15315
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.kusitms.domain.usecase.home

import com.kusitms.domain.repository.HomeRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class PostAttendCheckUseCase @Inject constructor(
private val homeRepository: HomeRepository
) {
operator fun invoke(
curriculumId: Int,
qrText: String
): Flow<Unit> = flow {
homeRepository.postAttendCheck(
curriculumId, qrText
).onSuccess {
emit(Unit)
}.onFailure {
throw it
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import com.bumptech.glide.Glide.init
import com.kusitms.domain.model.home.AttendCurrentModel
import com.kusitms.domain.model.home.AttendInfoModel
import com.kusitms.domain.model.home.AttendModel
import com.kusitms.domain.usecase.home.GetAttendCurrentListUseCase
import com.kusitms.domain.usecase.home.GetAttendInfoUseCase
import com.kusitms.domain.usecase.home.GetAttendScoreUseCase
import com.kusitms.domain.usecase.home.*
import com.kusitms.presentation.R
import com.kusitms.presentation.common.ui.theme.KusitmsColorPalette
import dagger.hilt.android.lifecycle.HiltViewModel
Expand All @@ -34,7 +32,9 @@ import javax.inject.Inject
class AttendViewModel @Inject constructor(
getAttendCurrentListUseCase: GetAttendCurrentListUseCase,
getAttendInfoUseCase: GetAttendInfoUseCase,
getAttendScoreUseCase: GetAttendScoreUseCase
getAttendScoreUseCase: GetAttendScoreUseCase,
postAttendCheckUseCase: PostAttendCheckUseCase,
getAttendQrUseCase: GetAttendQrUseCase
):ViewModel() {

val attendListInit: StateFlow<List<AttendCurrentModel>> = getAttendCurrentListUseCase()
Expand Down Expand Up @@ -68,10 +68,6 @@ class AttendViewModel @Inject constructor(
initialValue = AttendModel(0, 0, 0, 0, "수료 가능한 점수에요")
)

private val _attendCurrentList = MutableStateFlow<List<AttendCurrentModel>>(emptyList())
val attendCurrentList : StateFlow<List<AttendCurrentModel>> = _attendCurrentList.asStateFlow()


fun formatDate(dateString: String): String {
val originalFormat = SimpleDateFormat("MM월 dd일", Locale.KOREA)
val targetFormat = SimpleDateFormat("M월 d일", Locale.KOREA)
Expand Down

0 comments on commit 5f15315

Please sign in to comment.