Skip to content

Commit

Permalink
Merge branch 'develop' into feature/53_self_study_data
Browse files Browse the repository at this point in the history
  • Loading branch information
ImGaram committed Sep 16, 2023
2 parents c5b222b + db625a4 commit ec7d119
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 7 deletions.
10 changes: 10 additions & 0 deletions app/src/main/java/com/msg/dotori/module/RemoteDataSourceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import com.msg.data.remote.datasource.auth.AuthDataSourceImpl
import com.msg.data.remote.datasource.auth.AuthDataSource
import com.msg.data.remote.datasource.music.MusicDataSource
import com.msg.data.remote.datasource.music.MusicDataSourceImpl
import com.msg.data.remote.datasource.self_study.SelfStudyDataSource
import com.msg.data.remote.datasource.self_study.SelfStudyDataSourceImpl
import com.msg.data.remote.datasource.student_info.StudentInfoDataSource
import com.msg.data.remote.datasource.student_info.StudentInfoDataSourceImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -17,4 +21,10 @@ interface RemoteDataSourceModule {

@Binds
fun bindsMusicDataSource(musicDataSourceImpl: MusicDataSourceImpl): MusicDataSource

@Binds
fun bindsStudentInfoDataSource(studentInfoDataSourceImpl: StudentInfoDataSourceImpl): StudentInfoDataSource

@Binds
fun bindsSelfStudyDataSource(selfStudyDataSourceImpl: SelfStudyDataSourceImpl): SelfStudyDataSource
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.msg.data.remote.datasource.self_study

interface SelfStudyDataSource {
suspend fun banSelfStudy(
role: String,
userId: Long
)

suspend fun banCancelSelfStudy(
role: String,
userId: Long
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.msg.data.remote.datasource.self_study

import com.msg.data.remote.network.SelfStudyApi
import com.msg.data.remote.util.safeApiCall
import javax.inject.Inject

class SelfStudyDataSourceImpl @Inject constructor(
private val selfStudyApi: SelfStudyApi
): SelfStudyDataSource {
override suspend fun banSelfStudy(role: String, userId: Long) = safeApiCall {
selfStudyApi.banSelfStudy(
role = role,
userId = userId
)
}

override suspend fun banCancelSelfStudy(role: String, userId: Long) = safeApiCall {
selfStudyApi.banCancelSelfStudy(
role = role,
userId = userId
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.msg.data.remote.datasource.student_info

import com.msg.data.remote.dto.student_info.SearchStudentInfoResponse
import com.msg.data.remote.dto.student_info.StudentInfoRequest
import com.msg.data.remote.dto.student_info.StudentInfoResponse

interface StudentInfoDataSource {
suspend fun getAllStudentInfo(): List<StudentInfoResponse>

suspend fun getSearchStudentInfo(
name: String?,
gender: String?,
classNum: String?,
grade: String?,
role: String?,
selfStudy: Boolean?,
): List<SearchStudentInfoResponse>

suspend fun modifyStudentInfo(body: StudentInfoRequest)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.msg.data.remote.datasource.student_info

import com.msg.data.remote.dto.student_info.SearchStudentInfoResponse
import com.msg.data.remote.dto.student_info.StudentInfoRequest
import com.msg.data.remote.dto.student_info.StudentInfoResponse
import com.msg.data.remote.network.StudentInfoApi
import com.msg.data.remote.util.safeApiCall
import javax.inject.Inject

class StudentInfoDataSourceImpl @Inject constructor(
private val studentInfoApi: StudentInfoApi
): StudentInfoDataSource {
override suspend fun getAllStudentInfo(): List<StudentInfoResponse> = safeApiCall {
studentInfoApi.getAllStudentInfo()
}

override suspend fun getSearchStudentInfo(
name: String?,
gender: String?,
classNum: String?,
grade: String?,
role: String?,
selfStudy: Boolean?,
): List<SearchStudentInfoResponse> = safeApiCall {
studentInfoApi.getSearchStudentInfo(
name = name,
gender = gender,
classNum = classNum,
grade = grade,
role = role,
selfStudy = selfStudy
)
}

override suspend fun modifyStudentInfo(body: StudentInfoRequest) = safeApiCall {
studentInfoApi.modifyStudentInfo(body)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.msg.data.remote.dto.student_info

enum class SelfStudyStatus {
CAN,
APPLIED,
CANT,
IMPOSSIBLE
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ data class StudentInfoResponse(
val memberName: String,
val stuNum: String,
val role: String,
val selfStudyStatus: String
val selfStudyStatus: SelfStudyStatus
)
12 changes: 6 additions & 6 deletions data/src/main/java/com/msg/data/remote/network/StudentInfoApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ interface StudentInfoApi {

@GET("/student-info/search")
suspend fun getSearchStudentInfo(
@Query("name") name: String,
@Query("gender") gender: String,
@Query("classNum") classNum: String,
@Query("grade") grade: Long,
@Query("role") role: String,
@Query("selfStudyCheck") selfStudyCheck: Boolean,
@Query("name") name: String? = null,
@Query("gender") gender: String? = null,
@Query("classNum") classNum: String? = null,
@Query("grade") grade: String? = null,
@Query("role") role: String? = null,
@Query("selfStudy") selfStudy: Boolean? = null,
): List<SearchStudentInfoResponse>

@PUT("/student-info/modify")
Expand Down

0 comments on commit ec7d119

Please sign in to comment.