Skip to content

Commit

Permalink
Merge pull request #99 from Mnseo/feature/attend-ui
Browse files Browse the repository at this point in the history
[FEAT] 출석 기능 UI 구현
  • Loading branch information
arinming authored Feb 6, 2024
2 parents 9428164 + 893ae81 commit ab67115
Show file tree
Hide file tree
Showing 30 changed files with 971 additions and 20 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>

<application
android:name=".KusitmsApp"
Expand Down
18 changes: 12 additions & 6 deletions data/src/main/java/com/kusitms/data/remote/api/KusitmsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import com.kusitms.data.remote.entity.response.FindPwCheckEmailResponse
import com.kusitms.data.remote.entity.response.LoginMemberProfileResponse
import com.kusitms.data.remote.entity.response.LoginResponse
import com.kusitms.data.remote.entity.response.SignInRequestResponse
import com.kusitms.data.remote.entity.response.home.CurriculumRecentPayload
import com.kusitms.data.remote.entity.response.home.HomeProfilePayload
import com.kusitms.data.remote.entity.response.home.MemberInfoDetailPayload
import com.kusitms.data.remote.entity.response.home.NoticeRecentPayload
import com.kusitms.data.remote.entity.response.home.TeamMatchingPayload
import com.kusitms.data.remote.entity.response.home.TeamProfilePayload
import com.kusitms.data.remote.entity.response.home.*
import com.kusitms.data.remote.entity.response.notice.CommentPayload
import com.kusitms.data.remote.entity.response.notice.CurriculumPayload
import com.kusitms.data.remote.entity.response.notice.FindPwCodeVerifyResponse
Expand Down Expand Up @@ -206,4 +201,15 @@ interface KusitmsApi {
suspend fun getProfileDetail(
@Path("memberId") memberId: Int,
): BaseResponse<ProfilePayload>


//이번주 커리큘럼 조회
@GET("v1/attend/info")
suspend fun getAttendInfo(): BaseResponse<AttendInfoPayload>


//커리큘럼 출석 조회
@GET("v1/attend/lists")
suspend fun getAttendCurrentList(): BaseResponse<List<AttendCurrentPayLoad>>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.kusitms.data.remote.entity.response.home

import com.kusitms.domain.model.home.AttendCurrentModel

data class AttendCurrentPayLoad(
val attendId: Int,
val curriculum: String,
val date: String,
val time: String,
val status:String
)

fun AttendCurrentPayLoad.toModel() =
AttendCurrentModel(
attendId = attendId ?: 0,
curriculum = curriculum ?: "",
date = date ?: "",
time = time ?: "",
status = status ?: ""
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.kusitms.data.remote.entity.response.home

import com.kusitms.domain.model.home.AttendInfoModel

data class AttendInfoPayload(
val curriculumId: Int,
val curriculumName: String,
val isAttended: Boolean,
val date: String
)

fun AttendInfoPayload.toModel() =
AttendInfoModel(
curriculumId = curriculumId ?: 0,
curriculumName = curriculumName ?: "",
isAttended = isAttended ?: false,
date = date ?: "2월 17일"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.kusitms.data.remote.entity.response.home

import com.kusitms.domain.model.home.AttendModel

data class AttendPayload(
val penalty: Int,
val present: Int,
val absent: Int,
val late: Int,
val passYn: String
)

fun AttendPayload.toModel() =
AttendModel(
penalty = penalty ?: 0,
present = present ?: 0,
absent = absent ?: 0,
late = late ?: 0,
passYn = passYn ?: "수료 가능한 점수에요"
)
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
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.response.home.toModel
import com.kusitms.domain.model.home.CurriculumRecentModel
import com.kusitms.domain.model.home.HomeProfileModel
import com.kusitms.domain.model.home.MemberInfoDetailModel
import com.kusitms.domain.model.home.NoticeRecentModel
import com.kusitms.domain.model.home.TeamMatchingModel
import com.kusitms.domain.model.home.*
import com.kusitms.domain.model.profile.ProfileModel
import com.kusitms.domain.repository.HomeRepository
import javax.inject.Inject

class HomeRepositoryImpl @Inject constructor(
private val kusitmsApi: KusitmsApi,
) : HomeRepository {


override suspend fun getMemberInfoHome(): Result<HomeProfileModel> {
return try {
val response = kusitmsApi.getMemberInfoHome()
Expand Down Expand Up @@ -99,4 +94,31 @@ class HomeRepositoryImpl @Inject constructor(
Result.failure(e)
}
}

override suspend fun getAttendCurrentList(): Result<List<AttendCurrentModel>> {
return try {
val response = kusitmsApi.getAttendCurrentList()

if(response.result.code == 200) {
Result.success(response.payload.map {it.toModel()})
} else {
Result.failure(RuntimeException("출석 리스트 조회 실패: ${response.result.message}"))
}
} catch (e: Exception) {
Result.failure(e)
}
}

override suspend fun getAttendInfo(): Result<AttendInfoModel> {
return try {
val response = kusitmsApi.getAttendInfo()
if(response.result.code == 200) {
Result.success(response.payload.toModel())
} else {
Result.failure(RuntimeException("출석 리스트 조회 실패: ${response.result.message}"))
}
} catch (e: Exception) {
Result.failure(e)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.kusitms.domain.model.home

data class AttendCurrentModel(
val attendId: Int,
val curriculum: String,
val date: String,
val time: String,
val status: String,
)

data class AttendModel(
val penalty: Int,
val present: Int,
val absent: Int,
val late: Int,
val passYn: String
)

data class AttendInfoModel(
val curriculumId: Int,
val curriculumName: String,
val isAttended: Boolean,
val date: String
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.kusitms.domain.repository

import com.kusitms.domain.model.home.CurriculumRecentModel
import com.kusitms.domain.model.home.HomeProfileModel
import com.kusitms.domain.model.home.MemberInfoDetailModel
import com.kusitms.domain.model.home.NoticeRecentModel
import com.kusitms.domain.model.home.TeamMatchingModel
import com.kusitms.domain.model.home.*
import com.kusitms.domain.model.profile.ProfileModel

interface HomeRepository {
Expand All @@ -16,4 +12,6 @@ interface HomeRepository {
suspend fun getMemberInfoList(
teamId: Int
): Result<List<ProfileModel>>
suspend fun getAttendCurrentList(): Result<List<AttendCurrentModel>>
suspend fun getAttendInfo(): Result<AttendInfoModel>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.kusitms.domain.usecase.home

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

class GetAttendCurrentListUseCase @Inject constructor(
private val homeRepository: HomeRepository
) {
operator fun invoke(): Flow<List<AttendCurrentModel>> = flow {
homeRepository.getAttendCurrentList()
.onSuccess {
emit(it)
}
.onFailure {
throw it
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.kusitms.domain.usecase.home

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

class GetAttendInfoUseCase @Inject constructor(
private val homeRepository: HomeRepository
) {
operator fun invoke(): Flow<AttendInfoModel> = flow {
homeRepository.getAttendInfo()
.onSuccess {
emit(it)
}.onFailure {
throw it
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class MemberSignOutUseCase@Inject constructor(
private val authRepository: AuthRepository
) {
suspend operator fun invoke(): Result<Unit> {
return authRepository.logOutMember()
return authRepository.signOutMember()
}
}
22 changes: 22 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ lottie-compose = "5.2.0"
#timber
timber = "5.0.1"

#camerax
camerax = "1.2.1"

#mlkit
mlkit = "17.2.0"

#retrofit2
okhttp3 = "4.10.0"
interceptor = "4.9.0"
Expand All @@ -67,6 +73,15 @@ junit = { group = "junit", name = "junit", version.ref = "junit" }
# timber
timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" }

# camera
camera2 = { group= "androidx.camera", name="camera-camera2", version.ref="camerax"}
camera2-lifecycle = { group= "androidx.camera", name="camera-lifecycle", version.ref="camerax"}
camera2-view = { group= "androidx.camera", name="camera-view", version.ref="camerax"}

#mlkit
mlkit = {group = "com.google.mlkit", name="barcode-scanning", version.ref="mlkit"}


# coroutines
coroutine = {group = "org.jetbrains.kotlinx", name="kotlinx-coroutines-android", version.ref="coroutines"}
# compose
Expand Down Expand Up @@ -136,6 +151,13 @@ coil = [
"coil-svg"
]

camerax=[
"camera2",
"camera2-lifecycle",
"camera2-view",
"mlkit"
]

lifecycle = [
"lifecycle-runtime",
"lifecycle-viewmodel"
Expand Down
3 changes: 3 additions & 0 deletions presentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ dependencies {
implementation(libs.hilt)
kapt(libs.hilt.compile)

//camera2
implementation(libs.bundles.camerax)

implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation "io.coil-kt:coil-compose:2.1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.kusitms.presentation.model.home.attend

import com.kusitms.domain.model.home.AttendCurrentModel

data class AttendUiState(
val curriculum:String,
val date: String,
val time: String,
val status: String,
val attendList: List<AttendCurrentModel> = emptyList()
)


val curriDummy = listOf(
AttendUiState("전체 OT", "9월 2일", "오후 1:59", "PRESENT"),
AttendUiState("전체 OT", "9월 9일","출석 실패", "ABSENT"),
AttendUiState("전문가 초청 강연", "9월 16일","오후 2:13", "LATE"),

)
Loading

0 comments on commit ab67115

Please sign in to comment.