diff --git a/data/src/main/java/com/kusitms/data/remote/entity/request/AttendCheckRequestBody.kt b/data/src/main/java/com/kusitms/data/remote/entity/request/AttendCheckRequestBody.kt index 8067755..749f76a 100644 --- a/data/src/main/java/com/kusitms/data/remote/entity/request/AttendCheckRequestBody.kt +++ b/data/src/main/java/com/kusitms/data/remote/entity/request/AttendCheckRequestBody.kt @@ -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 ) +} \ No newline at end of file diff --git a/data/src/main/java/com/kusitms/data/repository/HomeRepositoryImpl.kt b/data/src/main/java/com/kusitms/data/repository/HomeRepositoryImpl.kt index 73f0cd5..0d2c34b 100644 --- a/data/src/main/java/com/kusitms/data/repository/HomeRepositoryImpl.kt +++ b/data/src/main/java/com/kusitms/data/repository/HomeRepositoryImpl.kt @@ -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 @@ -149,4 +151,20 @@ class HomeRepositoryImpl @Inject constructor( Result.failure(e) } } + + override suspend fun postAttendCheck(curriculumId: Int, qrText: String): Result { + 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) + } + } } \ No newline at end of file diff --git a/domain/src/main/java/com/kusitms/domain/repository/HomeRepository.kt b/domain/src/main/java/com/kusitms/domain/repository/HomeRepository.kt index 3bd7775..d5493f0 100644 --- a/domain/src/main/java/com/kusitms/domain/repository/HomeRepository.kt +++ b/domain/src/main/java/com/kusitms/domain/repository/HomeRepository.kt @@ -9,13 +9,10 @@ interface HomeRepository { suspend fun getCurriculumRecent(): Result suspend fun getTeamMatch(): Result> suspend fun getMemberInfoDetail(): Result - suspend fun getMemberInfoList( - teamId: Int - ): Result> + suspend fun getMemberInfoList(teamId: Int): Result> suspend fun getAttendCurrentList(): Result> suspend fun getAttendInfo(): Result suspend fun getAttendScore(): Result - suspend fun getAttendQrText( - curriculumId: Int - ): Result + suspend fun getAttendQrText(curriculumId: Int): Result + suspend fun postAttendCheck(curriculumId: Int, qrText: String): Result } \ No newline at end of file