diff --git a/app/src/main/java/com/afs/tutrd/data/constant/firestore/Collection.kt b/app/src/main/java/com/afs/tutrd/data/constant/firestore/Collection.kt index 124ceac..d27b05f 100644 --- a/app/src/main/java/com/afs/tutrd/data/constant/firestore/Collection.kt +++ b/app/src/main/java/com/afs/tutrd/data/constant/firestore/Collection.kt @@ -2,4 +2,5 @@ package com.afs.tutrd.data.constant.firestore object Collection { const val CLASSROOM = "classroom" + const val USER = "user" } \ No newline at end of file diff --git a/app/src/main/java/com/afs/tutrd/data/model/classroom/Classroom.kt b/app/src/main/java/com/afs/tutrd/data/model/classroom/Classroom.kt deleted file mode 100644 index 1b7ead3..0000000 --- a/app/src/main/java/com/afs/tutrd/data/model/classroom/Classroom.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.afs.tutrd.data.model.classroom - -import com.google.firebase.firestore.PropertyName - -// TODO 이름 바꾸기 (사유: 겹침) -data class Classroom( - @PropertyName("classroomName") - val classroomName: String = "", - @PropertyName("classroomProfileColor") - val classroomProfileColor: String = "", - @PropertyName("classroomProfileImage") - val classroomProfileImage: String = "", - @PropertyName("fixedCount") - val fixedCount: Int = 0, - @PropertyName("payMethod") - val payMethod: String = "" - // TODO 나머지 채우기 / 근데 모델 이렇게 따로 쓸건지 질문 하기 (파이어스토어랑 주고 받는 모델 / 뷰에서 쓰는 모델) -) diff --git a/app/src/main/java/com/afs/tutrd/data/model/classroom/ClassroomData.kt b/app/src/main/java/com/afs/tutrd/data/model/classroom/ClassroomData.kt new file mode 100644 index 0000000..992c21e --- /dev/null +++ b/app/src/main/java/com/afs/tutrd/data/model/classroom/ClassroomData.kt @@ -0,0 +1,31 @@ +package com.afs.tutrd.data.model.classroom + +import com.google.firebase.firestore.PropertyName + +// TODO 이름 바꾸기 (사유: 겹침) +data class ClassroomData( + @PropertyName("classroomName") + val classroomName: String = "", + @PropertyName("classroomProfileColor") + val classroomProfileColor: String = "", + @PropertyName("classroomProfileImage") + val classroomProfileImage: String = "", + @PropertyName("fixedCount") + val fixedCount: Int = 0, + @PropertyName("payMethod") + val payMethod: String = "", + @PropertyName("repetition") + val repetition: RepetitionData = RepetitionData(), + @PropertyName("timetable") + val timetable: List = emptyList(), + @PropertyName("tuitionFee") + val tuitionFee: Int = 0, + @PropertyName("tuitionFeeUnit") + val tuitionFeeUnit: String = "", + @PropertyName("tutees") + val tutees: List = emptyList(), + @PropertyName("tutorId") + val tutorId: String = "", + @PropertyName("tutoring") + val tutoring: List = emptyList(), +) diff --git a/app/src/main/java/com/afs/tutrd/data/model/classroom/HomeworkData.kt b/app/src/main/java/com/afs/tutrd/data/model/classroom/HomeworkData.kt new file mode 100644 index 0000000..8e1aff0 --- /dev/null +++ b/app/src/main/java/com/afs/tutrd/data/model/classroom/HomeworkData.kt @@ -0,0 +1,11 @@ +package com.afs.tutrd.data.model.classroom + +import com.google.firebase.firestore.PropertyName + +data class HomeworkData( + @PropertyName("content") + val content: String = "", + @get:PropertyName("isDone") + @set:PropertyName("isDone") + var isDone: Boolean = false +) diff --git a/app/src/main/java/com/afs/tutrd/data/model/classroom/HomeworkImageData.kt b/app/src/main/java/com/afs/tutrd/data/model/classroom/HomeworkImageData.kt new file mode 100644 index 0000000..9e24deb --- /dev/null +++ b/app/src/main/java/com/afs/tutrd/data/model/classroom/HomeworkImageData.kt @@ -0,0 +1,10 @@ +package com.afs.tutrd.data.model.classroom + +import com.google.firebase.firestore.PropertyName + +data class HomeworkImageData( + @PropertyName("description") + val description: String = "", + @PropertyName("image") + val image: String = "" +) diff --git a/app/src/main/java/com/afs/tutrd/data/model/classroom/ProgressImagesData.kt b/app/src/main/java/com/afs/tutrd/data/model/classroom/ProgressImagesData.kt new file mode 100644 index 0000000..56c7384 --- /dev/null +++ b/app/src/main/java/com/afs/tutrd/data/model/classroom/ProgressImagesData.kt @@ -0,0 +1,10 @@ +package com.afs.tutrd.data.model.classroom + +import com.google.firebase.firestore.PropertyName + +data class ProgressImagesData( + @PropertyName("description") + val description: String = "", + @PropertyName("image") + val image: String = "" +) diff --git a/app/src/main/java/com/afs/tutrd/data/model/classroom/RepetitionData.kt b/app/src/main/java/com/afs/tutrd/data/model/classroom/RepetitionData.kt new file mode 100644 index 0000000..da87795 --- /dev/null +++ b/app/src/main/java/com/afs/tutrd/data/model/classroom/RepetitionData.kt @@ -0,0 +1,18 @@ +package com.afs.tutrd.data.model.classroom + +import com.google.firebase.firestore.PropertyName + +data class RepetitionData( + @PropertyName("date") + val date: Int = 0, + @PropertyName("day") + val day: String = "", + @PropertyName("interval") + val interval: Int = 0, + @PropertyName("month") + val month: Int = 0, + @PropertyName("type") + val type: Int = 0, + @PropertyName("week") + val week: Int = 0, +) diff --git a/app/src/main/java/com/afs/tutrd/data/model/classroom/TimetableData.kt b/app/src/main/java/com/afs/tutrd/data/model/classroom/TimetableData.kt new file mode 100644 index 0000000..417cad8 --- /dev/null +++ b/app/src/main/java/com/afs/tutrd/data/model/classroom/TimetableData.kt @@ -0,0 +1,16 @@ +package com.afs.tutrd.data.model.classroom + +import com.google.firebase.Timestamp +import com.google.firebase.firestore.PropertyName + +data class TimetableData( + @PropertyName("classHours") + val classHours: Int = 0, + @PropertyName("endDate") + val endDate: Timestamp = Timestamp.now(), + @PropertyName("repetition") + val repetition: RepetitionData = RepetitionData(), + @PropertyName("startDate") + val startDate: Timestamp = Timestamp.now() + +) diff --git a/app/src/main/java/com/afs/tutrd/data/model/classroom/TutoringData.kt b/app/src/main/java/com/afs/tutrd/data/model/classroom/TutoringData.kt new file mode 100644 index 0000000..cf376ae --- /dev/null +++ b/app/src/main/java/com/afs/tutrd/data/model/classroom/TutoringData.kt @@ -0,0 +1,28 @@ +package com.afs.tutrd.data.model.classroom + +import com.google.firebase.Timestamp +import com.google.firebase.firestore.PropertyName + +data class TutoringData( + @PropertyName("attendance") + val attendance: List = emptyList(), + @PropertyName("dateTime") + val dateTime: Timestamp = Timestamp.now(), + @PropertyName("elapsedTime") + val elapsedTime: Int = 0, + @PropertyName("homework") + val homework: List = emptyList(), + @PropertyName("homeworkImages") + val homeworkImages: List = emptyList(), + @get:PropertyName("isComplete") + @set:PropertyName("isComplete") + var isComplete: Boolean = false, + @PropertyName("progress") + val progress: List = emptyList(), + @PropertyName("progressImages") + val progressImages: List = emptyList(), + @PropertyName("status") + val status: Int = 0, + @PropertyName("tutoringId") + val tutoringId: String = "", +) diff --git a/app/src/main/java/com/afs/tutrd/data/repository/classroom/ClassroomRepositoryImpl.kt b/app/src/main/java/com/afs/tutrd/data/repository/classroom/ClassroomRepositoryImpl.kt index 08847c5..52c344d 100644 --- a/app/src/main/java/com/afs/tutrd/data/repository/classroom/ClassroomRepositoryImpl.kt +++ b/app/src/main/java/com/afs/tutrd/data/repository/classroom/ClassroomRepositoryImpl.kt @@ -2,7 +2,7 @@ package com.afs.tutrd.data.repository.classroom import com.afs.tutrd.data.constant.firestore.Collection import com.afs.tutrd.data.constant.firestore.Field -import com.afs.tutrd.data.model.classroom.Classroom +import com.afs.tutrd.data.model.classroom.ClassroomData import com.afs.tutrd.di.qualifier.IoDispatcher import com.afs.tutrd.domain.repository.classroom.ClassroomRepository import com.google.firebase.firestore.FirebaseFirestore @@ -15,12 +15,12 @@ class ClassroomRepositoryImpl @Inject constructor( private val firestore: FirebaseFirestore, @IoDispatcher private val dispatcher: CoroutineDispatcher ) : ClassroomRepository { - override suspend fun fetchClassroomList(tutorId: String): Result> = + override suspend fun fetchClassroomList(tutorId: String): Result> = withContext(dispatcher) { runCatching { firestore.collection(Collection.CLASSROOM) .whereEqualTo(Field.TUTOR_ID, tutorId) - .get().await().toObjects(Classroom::class.java) + .get().await().toObjects(ClassroomData::class.java) } } } \ No newline at end of file diff --git a/app/src/main/java/com/afs/tutrd/di/RepositoryModule.kt b/app/src/main/java/com/afs/tutrd/di/RepositoryModule.kt index 772e6f8..91bdd1f 100644 --- a/app/src/main/java/com/afs/tutrd/di/RepositoryModule.kt +++ b/app/src/main/java/com/afs/tutrd/di/RepositoryModule.kt @@ -12,7 +12,7 @@ import dagger.hilt.components.SingletonComponent interface RepositoryModule { @Binds - fun bindHealthCheckRepository( + fun bindClassroomRepository( classroomRepositoryImpl: ClassroomRepositoryImpl ): ClassroomRepository } \ No newline at end of file diff --git a/app/src/main/java/com/afs/tutrd/domain/repository/classroom/ClassroomRepository.kt b/app/src/main/java/com/afs/tutrd/domain/repository/classroom/ClassroomRepository.kt index f818ca4..bfa0258 100644 --- a/app/src/main/java/com/afs/tutrd/domain/repository/classroom/ClassroomRepository.kt +++ b/app/src/main/java/com/afs/tutrd/domain/repository/classroom/ClassroomRepository.kt @@ -1,7 +1,7 @@ package com.afs.tutrd.domain.repository.classroom -import com.afs.tutrd.data.model.classroom.Classroom +import com.afs.tutrd.data.model.classroom.ClassroomData interface ClassroomRepository { - suspend fun fetchClassroomList(tutorId: String): Result> + suspend fun fetchClassroomList(tutorId: String): Result> } \ No newline at end of file diff --git a/app/src/main/java/com/afs/tutrd/presentation/classroom/ClassroomViewModel.kt b/app/src/main/java/com/afs/tutrd/presentation/classroom/ClassroomViewModel.kt index ef0516e..eaec816 100644 --- a/app/src/main/java/com/afs/tutrd/presentation/classroom/ClassroomViewModel.kt +++ b/app/src/main/java/com/afs/tutrd/presentation/classroom/ClassroomViewModel.kt @@ -17,7 +17,7 @@ import javax.inject.Inject @HiltViewModel class ClassroomViewModel @Inject constructor( - private val classroomRepository: ClassroomRepository + private val classroomRepository: ClassroomRepository, ):BaseViewModel( initialState = ClassroomState.init() ) { diff --git a/app/src/main/java/com/afs/tutrd/presentation/classroom/contract/ClassroomState.kt b/app/src/main/java/com/afs/tutrd/presentation/classroom/contract/ClassroomState.kt index 53efd2a..202ea99 100644 --- a/app/src/main/java/com/afs/tutrd/presentation/classroom/contract/ClassroomState.kt +++ b/app/src/main/java/com/afs/tutrd/presentation/classroom/contract/ClassroomState.kt @@ -1,10 +1,10 @@ package com.afs.tutrd.presentation.classroom.contract import com.afs.tutrd.common.base.UiState -import com.afs.tutrd.data.model.classroom.Classroom +import com.afs.tutrd.data.model.classroom.ClassroomData data class ClassroomState( - val classroomList: List + val classroomList: List ): UiState() { companion object { fun init() = ClassroomState(