Skip to content

Commit

Permalink
Merge pull request #62 from Team-Ampersand/feature/61_self_study_domain
Browse files Browse the repository at this point in the history
🔀 :: (#61) self study domain
  • Loading branch information
ImGaram authored Sep 18, 2023
2 parents d0eafbd + 1938f2d commit dc9528d
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package com.msg.data.remote.dto.self_study

import com.msg.domain.model.self_study.SelfStudyInfoResponseModel

data class SelfStudyInfoResponse(
val count: Int,
val limit: Int,
val selfStudyStatus: String,
val selfStudyStatus: String
)

fun SelfStudyInfoResponse.asSelfStudyInfoResponseModel() = SelfStudyInfoResponseModel(
count = count,
limit = limit,
selfStudyStatus = selfStudyStatus
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.msg.data.remote.dto.self_study

import com.msg.domain.model.self_study.SelfStudyListResponseModel

data class SelfStudyListResponse(
val rank: Int,
val id: Int,
Expand All @@ -8,3 +10,12 @@ data class SelfStudyListResponse(
val gender: String,
val selfStudyCheck: Boolean
)

fun SelfStudyListResponse.asSelfStudyListResponseModel() = SelfStudyListResponseModel(
rank = rank,
id = id,
stuNum = stuNum,
memberName = memberName,
gender = gender,
selfStudyCheck = selfStudyCheck
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
package com.msg.data.repository

import com.msg.data.remote.datasource.self_study.SelfStudyDataSource
import com.msg.data.remote.dto.self_study.asSelfStudyInfoResponseModel
import com.msg.data.remote.dto.self_study.asSelfStudyListResponseModel
import com.msg.domain.model.self_study.SelfStudyInfoResponseModel
import com.msg.domain.model.self_study.SelfStudyListResponseModel
import com.msg.domain.repository.SelfStudyRepository
import javax.inject.Inject

class SelfStudyRepositoryImpl @Inject constructor(
private val selfStudyDataSource: SelfStudyDataSource
): SelfStudyRepository {
override suspend fun getSelfStudyInfo(role: String): SelfStudyInfoResponseModel =
selfStudyDataSource.getSelfStudyInfo(role = role).asSelfStudyInfoResponseModel()

override suspend fun getSelfStudyList(role: String): List<SelfStudyListResponseModel> =
selfStudyDataSource.getSelfStudyList(role = role).map { it.asSelfStudyListResponseModel() }

override suspend fun searchSelfStudyStudent(
role: String,
name: String?,
gender: String?,
classNum: String?,
grade: Int?
): List<SelfStudyListResponseModel> = selfStudyDataSource.searchSelfStudyStudent(
role = role,
name = name,
gender = gender,
classNum = classNum,
grade = grade
).map { it.asSelfStudyListResponseModel() }

override suspend fun banSelfStudy(role: String, userId: Long) =
selfStudyDataSource.banSelfStudy(
role = role,
Expand All @@ -18,4 +42,23 @@ class SelfStudyRepositoryImpl @Inject constructor(
role = role,
userId = userId
)

override suspend fun selfStudy(role: String) =
selfStudyDataSource.selfStudy(role)

override suspend fun cancelSelfStudy(role: String) =
selfStudyDataSource.cancelSelfStudy(role)

override suspend fun changeSelfStudyLimit(role: String, limit: Int) =
selfStudyDataSource.changeSelfStudyLimit(
role = role,
limit = limit
)

override suspend fun checkSelfStudy(role: String, memberId: Long, selfStudyCheck: Boolean) =
selfStudyDataSource.checkSelfStudy(
role = role,
memberId = memberId,
selfStudyCheck = selfStudyCheck
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.msg.domain.model.self_study

data class SelfStudyInfoResponseModel(
val count: Int,
val limit: Int,
val selfStudyStatus: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.msg.domain.model.self_study

data class SelfStudyListResponseModel(
val rank: Int,
val id: Int,
val stuNum: String,
val memberName: String,
val gender: String,
val selfStudyCheck: Boolean
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
package com.msg.domain.repository

import com.msg.domain.model.self_study.SelfStudyInfoResponseModel
import com.msg.domain.model.self_study.SelfStudyListResponseModel

interface SelfStudyRepository {
suspend fun getSelfStudyInfo(
role: String
): SelfStudyInfoResponseModel

suspend fun getSelfStudyList(
role: String
): List<SelfStudyListResponseModel>

suspend fun searchSelfStudyStudent(
role: String,
name: String?,
gender: String?,
classNum: String?,
grade: Int?
): List<SelfStudyListResponseModel>

suspend fun banSelfStudy(
role: String,
userId: Long
Expand All @@ -10,4 +29,23 @@ interface SelfStudyRepository {
role: String,
userId: Long
)

suspend fun selfStudy(
role: String
)

suspend fun cancelSelfStudy(
role: String
)

suspend fun changeSelfStudyLimit(
role: String,
limit: Int
)

suspend fun checkSelfStudy(
role: String,
memberId: Long,
selfStudyCheck: Boolean
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.domain.usecase.self_study

import com.msg.domain.repository.SelfStudyRepository
import javax.inject.Inject

class CancelSelfStudyUseCase @Inject constructor(
private val selfStudyRepository: SelfStudyRepository
) {
suspend operator fun invoke(role: String) = kotlin.runCatching {
selfStudyRepository.cancelSelfStudy(role = role)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.msg.domain.usecase.self_study

import com.msg.domain.repository.SelfStudyRepository
import javax.inject.Inject

class ChangeSelfStudyLimitUseCase @Inject constructor(
private val selfStudyRepository: SelfStudyRepository
) {
suspend operator fun invoke(
role: String,
limit: Int
) = kotlin.runCatching {
selfStudyRepository.changeSelfStudyLimit(
role = role,
limit = limit
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.msg.domain.usecase.self_study

import com.msg.domain.repository.SelfStudyRepository
import javax.inject.Inject

class CheckSelfStudyUseCase @Inject constructor(
private val selfStudyRepository: SelfStudyRepository
) {
suspend operator fun invoke(
role: String,
memberId: Long,
selfStudyCheck: Boolean
) = kotlin.runCatching {
selfStudyRepository.checkSelfStudy(
role = role,
memberId = memberId,
selfStudyCheck = selfStudyCheck
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.domain.usecase.self_study

import com.msg.domain.repository.SelfStudyRepository
import javax.inject.Inject

class GetSelfStudyInfoUseCase @Inject constructor(
private val selfStudyRepository: SelfStudyRepository
) {
suspend operator fun invoke(role: String) = kotlin.runCatching {
selfStudyRepository.getSelfStudyInfo(role = role)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.domain.usecase.self_study

import com.msg.domain.repository.SelfStudyRepository
import javax.inject.Inject

class GetSelfStudyListUseCase @Inject constructor(
private val selfStudyRepository: SelfStudyRepository
) {
suspend operator fun invoke(role: String) = kotlin.runCatching {
selfStudyRepository.getSelfStudyList(role = role)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.msg.domain.usecase.self_study

import com.msg.domain.repository.SelfStudyRepository
import javax.inject.Inject

class SearchSelfStudyStudentUseCase @Inject constructor(
private val selfStudyRepository: SelfStudyRepository
) {
suspend operator fun invoke(
role: String,
name: String?,
gender: String?,
classNum: String?,
grade: Int?
) = kotlin.runCatching {
selfStudyRepository.searchSelfStudyStudent(
role = role,
name = name,
gender = gender,
classNum = classNum,
grade = grade

)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.domain.usecase.self_study

import com.msg.domain.repository.SelfStudyRepository
import javax.inject.Inject

class SelfStudyUseCase @Inject constructor(
private val selfStudyRepository: SelfStudyRepository
) {
suspend operator fun invoke(role: String) = kotlin.runCatching {
selfStudyRepository.selfStudy(role = role)
}
}

0 comments on commit dc9528d

Please sign in to comment.