diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 36f220b..86968c5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,6 +6,9 @@ + + diff --git a/data/src/main/java/com/kusitms/data/remote/api/KusitmsApi.kt b/data/src/main/java/com/kusitms/data/remote/api/KusitmsApi.kt index 72112f3..4d35c45 100644 --- a/data/src/main/java/com/kusitms/data/remote/api/KusitmsApi.kt +++ b/data/src/main/java/com/kusitms/data/remote/api/KusitmsApi.kt @@ -209,5 +209,21 @@ interface KusitmsApi { @GET("v1/attend") suspend fun getAttendScore(): BaseResponse + //출석 QR 조회 + @GET("v1/attend/text/{curriculumId}") + suspend fun getQrText( + @Path("curriculumId") curriculumId: Int + ):BaseResponse + + //결석 처리 + @POST("v1/attend/absent/{curriculumId}") + suspend fun postAbsent( + @Path("curriculumId") curriculumId: Int + ): BaseResponse + //출석 처리 + @POST("v1/attend") + suspend fun attendCheck( + @Body attendCheckRequestBody: AttendCheckRequestBody + ): BaseResponse } \ No newline at end of file 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 new file mode 100644 index 0000000..8067755 --- /dev/null +++ b/data/src/main/java/com/kusitms/data/remote/entity/request/AttendCheckRequestBody.kt @@ -0,0 +1,13 @@ +package com.kusitms.data.remote.entity.request + +import com.kusitms.domain.model.home.AttendCheckModel + +data class AttendCheckRequestBody( + val curriculumId: Int, + val text: String +) + +fun AttendCheckModel.toBody() = + AttendCheckRequestBody( + curriculumId, text + ) diff --git a/data/src/main/java/com/kusitms/data/remote/entity/response/home/AttendQrTextPayload.kt b/data/src/main/java/com/kusitms/data/remote/entity/response/home/AttendQrTextPayload.kt new file mode 100644 index 0000000..d913f0a --- /dev/null +++ b/data/src/main/java/com/kusitms/data/remote/entity/response/home/AttendQrTextPayload.kt @@ -0,0 +1,13 @@ +package com.kusitms.data.remote.entity.response.home + +import com.kusitms.domain.model.home.AttendQRModel + +data class AttendQrTextPayload( + val qrText: String +) + +fun AttendQrTextPayload.toModel() = + AttendQRModel( + qrText = qrText + ) + 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 533281e..73f0cd5 100644 --- a/data/src/main/java/com/kusitms/data/repository/HomeRepositoryImpl.kt +++ b/data/src/main/java/com/kusitms/data/repository/HomeRepositoryImpl.kt @@ -134,4 +134,19 @@ class HomeRepositoryImpl @Inject constructor( Result.failure(e) } } + + override suspend fun getAttendQrText( + curriculumId: Int + ): Result { + return try { + val response = kusitmsApi.getQrText(curriculumId) + if(response.result.code == 200) { + Result.success(response.payload.toModel()) + } else { + Result.failure(RuntimeException("QR 코드 조회 실패: ${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/model/home/AttendCheckModel.kt b/domain/src/main/java/com/kusitms/domain/model/home/AttendCheckModel.kt new file mode 100644 index 0000000..598b54b --- /dev/null +++ b/domain/src/main/java/com/kusitms/domain/model/home/AttendCheckModel.kt @@ -0,0 +1,10 @@ +package com.kusitms.domain.model.home + +data class AttendCheckModel( + val curriculumId: Int, + val text :String +) + +data class AttendQRModel( + val qrText: String +) 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 a6da6c3..3bd7775 100644 --- a/domain/src/main/java/com/kusitms/domain/repository/HomeRepository.kt +++ b/domain/src/main/java/com/kusitms/domain/repository/HomeRepository.kt @@ -15,4 +15,7 @@ interface HomeRepository { suspend fun getAttendCurrentList(): Result> suspend fun getAttendInfo(): Result suspend fun getAttendScore(): Result + suspend fun getAttendQrText( + curriculumId: Int + ): Result } \ No newline at end of file diff --git a/domain/src/main/java/com/kusitms/domain/usecase/home/GetAttendQrUseCase.kt b/domain/src/main/java/com/kusitms/domain/usecase/home/GetAttendQrUseCase.kt new file mode 100644 index 0000000..a5b7b8c --- /dev/null +++ b/domain/src/main/java/com/kusitms/domain/usecase/home/GetAttendQrUseCase.kt @@ -0,0 +1,23 @@ +package com.kusitms.domain.usecase.home + +import com.kusitms.domain.model.home.AttendQRModel +import com.kusitms.domain.repository.HomeRepository +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import javax.inject.Inject + +class GetAttendQrUseCase @Inject constructor( + private val homeRepository: HomeRepository +) { + operator fun invoke( + curriculumId: Int + ): Flow = flow { + homeRepository.getAttendQrText( + curriculumId = curriculumId + ).onSuccess { + return@flow emit(it) + }.onFailure { + throw it + } + } +} \ No newline at end of file