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 156575c commit 5181086
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ data class AttendCheckRequestBody(
val text: String
)

fun AttendCheckModel.toBody() =
AttendCheckRequestBody(
curriculumId, text
fun mapToAttendCheckRequestBody(model: AttendCheckModel): AttendCheckRequestBody {
return AttendCheckRequestBody(
curriculumId = model.curriculumId,
text = model.text
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.kusitms.data.repository

import android.os.Build.VERSION_CODES.P
import com.kusitms.data.remote.api.KusitmsApi
import com.kusitms.data.remote.entity.request.AttendCheckRequestBody
import com.kusitms.data.remote.entity.request.mapToAttendCheckRequestBody
import com.kusitms.data.remote.entity.response.home.toModel
import com.kusitms.domain.model.home.*
import com.kusitms.domain.model.profile.ProfileModel
Expand Down Expand Up @@ -149,4 +151,20 @@ class HomeRepositoryImpl @Inject constructor(
Result.failure(e)
}
}

override suspend fun postAttendCheck(curriculumId: Int, qrText: String): Result<Unit> {
return try {
val model = AttendCheckModel(curriculumId, qrText)
val request = mapToAttendCheckRequestBody(model)
val response = kusitmsApi.attendCheck(request)

if(response.result.code == 200) {
Result.success(Unit)
} else {
Result.failure(RuntimeException("출석 실패: ${response.result.message}"))
}
} catch(e: Exception) {
Result.failure(e)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ interface HomeRepository {
suspend fun getCurriculumRecent(): Result<CurriculumRecentModel>
suspend fun getTeamMatch(): Result<List<TeamMatchingModel>>
suspend fun getMemberInfoDetail(): Result<MemberInfoDetailModel>
suspend fun getMemberInfoList(
teamId: Int
): Result<List<ProfileModel>>
suspend fun getMemberInfoList(teamId: Int): Result<List<ProfileModel>>
suspend fun getAttendCurrentList(): Result<List<AttendCurrentModel>>
suspend fun getAttendInfo(): Result<AttendInfoModel>
suspend fun getAttendScore(): Result<AttendModel>
suspend fun getAttendQrText(
curriculumId: Int
): Result<AttendQRModel>
suspend fun getAttendQrText(curriculumId: Int): Result<AttendQRModel>
suspend fun postAttendCheck(curriculumId: Int, qrText: String): Result<Unit>
}

0 comments on commit 5181086

Please sign in to comment.