Skip to content

Commit

Permalink
Merge pull request #47 from team-haribo/feature/46-write-the-logic-st…
Browse files Browse the repository at this point in the history
…udent-management

🔀 :: (#46) - write the logic student management
  • Loading branch information
diejdkll authored Feb 12, 2024
2 parents 5af08ea + 7282ab1 commit 4766bbb
Show file tree
Hide file tree
Showing 24 changed files with 719 additions and 116 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
package com.goms.data.repository.council

import com.goms.model.request.council.AuthorityRequest
import com.goms.model.response.council.LateResponse
import com.goms.model.response.council.StudentResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.datetime.LocalDate
import java.util.UUID

interface CouncilRepository {
suspend fun getStudentList(): Flow<List<StudentResponse>>

suspend fun changeAuthority(body: AuthorityRequest): Flow<Unit>

suspend fun setBlackList(accountIdx: UUID): Flow<Unit>

suspend fun deleteBlackList(accountIdx: UUID): Flow<Unit>

suspend fun studentSearch(
grade: Int?,
gender: String?,
major: String?,
name: String?,
isBlackList: Boolean?,
authority: String?
): Flow<List<StudentResponse>>

suspend fun deleteOuting(accountIdx: UUID): Flow<Unit>

suspend fun getLateList(date: LocalDate): Flow<List<LateResponse>>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.goms.data.repository.council

import com.goms.model.request.council.AuthorityRequest
import com.goms.model.response.council.LateResponse
import com.goms.model.response.council.StudentResponse
import com.goms.network.datasource.council.CouncilDataSource
import kotlinx.coroutines.flow.Flow
import kotlinx.datetime.LocalDate
Expand All @@ -10,6 +12,40 @@ import javax.inject.Inject
class CouncilRepositoryImpl @Inject constructor(
private val remoteCouncilDataSource: CouncilDataSource
) : CouncilRepository {
override suspend fun getStudentList(): Flow<List<StudentResponse>> {
return remoteCouncilDataSource.getStudentList()
}

override suspend fun changeAuthority(body: AuthorityRequest): Flow<Unit> {
return remoteCouncilDataSource.changeAuthority(body = body)
}

override suspend fun setBlackList(accountIdx: UUID): Flow<Unit> {
return remoteCouncilDataSource.setBlackList(accountIdx = accountIdx)
}

override suspend fun deleteBlackList(accountIdx: UUID): Flow<Unit> {
return remoteCouncilDataSource.deleteBlackList(accountIdx = accountIdx)
}

override suspend fun studentSearch(
grade: Int?,
gender: String?,
major: String?,
name: String?,
isBlackList: Boolean?,
authority: String?
): Flow<List<StudentResponse>> {
return remoteCouncilDataSource.studentSearch(
grade = grade,
gender = gender,
major = major,
name = name,
isBlackList = isBlackList,
authority = authority
)
}

override suspend fun deleteOuting(accountIdx: UUID): Flow<Unit> {
return remoteCouncilDataSource.deleteOuting(accountIdx = accountIdx)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ fun MultipleSelectorBottomSheet(
list3: List<String>,
selected3: String,
itemChange3: (String) -> Unit,
subTitle4: String,
list4: List<String>,
selected4: String,
itemChange4: (String) -> Unit,
closeSheet: () -> Unit
) {
var componentWidth by remember { mutableStateOf( 0.dp ) }
Expand Down Expand Up @@ -135,6 +139,27 @@ fun MultipleSelectorBottomSheet(
}
}
}
Spacer(modifier = Modifier.height(8.dp))
Text(
text = subTitle4,
style = typography.titleSmall,
fontWeight = FontWeight.SemiBold,
color = colors.WHITE
)
LazyRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
items(list4.size) {
AdminBottomSheetButton(
modifier = Modifier.widthIn((componentWidth - 16.dp * list4.lastIndex) / list4.size),
text = list4[it],
selected = selected4 == list4[it]
) {
itemChange4(list4[it])
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.goms.domain.council

import com.goms.data.repository.council.CouncilRepository
import com.goms.model.request.council.AuthorityRequest
import javax.inject.Inject

class ChangeAuthorityUseCase @Inject constructor(
private val councilRepository: CouncilRepository
) {
suspend operator fun invoke(body: AuthorityRequest) = kotlin.runCatching {
councilRepository.changeAuthority(body = body)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.goms.domain.council

import com.goms.data.repository.council.CouncilRepository
import java.util.UUID
import javax.inject.Inject

class DeleteBlackListUseCase @Inject constructor(
private val councilRepository: CouncilRepository
) {
suspend operator fun invoke(accountIdx: UUID) = kotlin.runCatching {
councilRepository.deleteBlackList(accountIdx = accountIdx)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.goms.domain.council

import com.goms.data.repository.council.CouncilRepository
import com.goms.model.response.council.StudentResponse
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class GetStudentListUseCase @Inject constructor(
private val councilRepository: CouncilRepository
) {
suspend operator fun invoke(): Flow<List<StudentResponse>> =
councilRepository.getStudentList()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.goms.domain.council

import com.goms.data.repository.council.CouncilRepository
import java.util.UUID
import javax.inject.Inject

class SetBlackListUseCase @Inject constructor(
private val councilRepository: CouncilRepository
) {
suspend operator fun invoke(accountIdx: UUID) = kotlin.runCatching {
councilRepository.setBlackList(accountIdx = accountIdx)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.goms.domain.council

import com.goms.data.repository.council.CouncilRepository
import com.goms.model.response.council.StudentResponse
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class StudentSearchUseCase @Inject constructor(
private val councilRepository: CouncilRepository
) {
suspend operator fun invoke(
grade: Int?,
gender: String?,
major: String?,
name: String?,
isBlackList: Boolean?,
authority: String?
): Flow<List<StudentResponse>> =
councilRepository.studentSearch(
grade = grade,
gender = gender,
major = major,
name = name,
isBlackList = isBlackList,
authority = authority
)
}
8 changes: 0 additions & 8 deletions core/model/src/main/java/com/goms/model/enum/Class.kt

This file was deleted.

6 changes: 3 additions & 3 deletions core/model/src/main/java/com/goms/model/enum/Grade.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.goms.model.enum

enum class Grade(val value: String, val enum: Int) {
FIRST_GRADE("1학년", 1),
SECOND_GRADE("2학년", 2),
THIRD_GRADE("3학년", 3)
FIRST_GRADE("1학년", 8),
SECOND_GRADE("2학년", 7),
THIRD_GRADE("3학년", 6)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.goms.model.request.council

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class AuthorityRequest(
@Json(name = "accountIdx") val accountIdx: String,
@Json(name = "authority") val authority: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.goms.model.response.council

import com.goms.model.enum.Authority
import com.goms.model.enum.Gender
import com.goms.model.enum.Major
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class StudentResponse(
@Json(name = "accountIdx") val accountIdx: String,
@Json(name = "name") val name: String,
@Json(name = "grade") val grade: Int,
@Json(name = "gender") val gender: Gender,
@Json(name = "major") val major: Major,
@Json(name = "profileUrl") val profileUrl: String?,
@Json(name = "authority") val authority: Authority,
@Json(name = "isBlackList") val isBlackList: Boolean
)
33 changes: 33 additions & 0 deletions core/network/src/main/java/com/goms/network/api/CouncilAPI.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,47 @@
package com.goms.network.api

import com.goms.model.request.council.AuthorityRequest
import com.goms.model.response.council.LateResponse
import com.goms.model.response.council.StudentResponse
import kotlinx.datetime.LocalDate
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
import java.util.UUID

interface CouncilAPI {
@GET("/api/v2/student-council/accounts")
suspend fun getStudentList(): List<StudentResponse>

@PATCH("/api/v2/student-council/authority")
suspend fun changeAuthority(
@Body body: AuthorityRequest
)

@POST("/api/v2/student-council/black-list/{accountIdx}")
suspend fun setBlackList(
@Path("accountIdx") accountIdx: UUID
)

@DELETE("/api/v2/student-council/black-list/{accountIdx}")
suspend fun deleteBlackList(
@Path("accountIdx") accountIdx: UUID
)

@GET("/api/v2/student-council/search")
suspend fun studentSearch(
@Query("grade") grade: Int?,
@Query("gender") gender: String?,
@Query("major") major: String?,
@Query("name") name: String?,
@Query("isBlackList") isBlackList: Boolean?,
@Query("authority") authority: String?
): List<StudentResponse>

@DELETE("/api/v2/student-council/outing/{accountIdx}")
suspend fun deleteOuting(
@Path("accountIdx") accountIdx: UUID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
package com.goms.network.datasource.council

import com.goms.model.request.council.AuthorityRequest
import com.goms.model.response.council.LateResponse
import com.goms.model.response.council.StudentResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.datetime.LocalDate
import java.util.UUID

interface CouncilDataSource {
suspend fun getStudentList(): Flow<List<StudentResponse>>

suspend fun changeAuthority(body: AuthorityRequest): Flow<Unit>

suspend fun setBlackList(accountIdx: UUID): Flow<Unit>

suspend fun deleteBlackList(accountIdx: UUID): Flow<Unit>

suspend fun studentSearch(
grade: Int?,
gender: String?,
major: String?,
name: String?,
isBlackList: Boolean?,
authority: String?
): Flow<List<StudentResponse>>

suspend fun deleteOuting(accountIdx: UUID): Flow<Unit>

suspend fun getLateList(date: LocalDate): Flow<List<LateResponse>>
Expand Down
Loading

0 comments on commit 4766bbb

Please sign in to comment.