Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: (#255) νƒ€μž… λ³€κ²½ API 였λ₯˜ μˆ˜μ • #124

Merged
merged 9 commits into from
Jan 17, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ interface AdminApi {

fun getStudentStatusListByGradeAndClassNum(grade: Int?, classNum: Int?): QueryStudentListByGradeAndClassNum

fun saveType(date: LocalDate, type: DirectorType)

fun updateType(date: LocalDate, type: DirectorType)
fun saveOrUpdateType(
date: LocalDate,
type: DirectorType,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,23 @@ class AdminUseCase(
status.studentId == userId && status.startPeriod <= statusPeriod && status.endPeriod >= statusPeriod
}?.type ?: StatusType.ATTENDANCE

override fun saveType(date: LocalDate, type: DirectorType) {
commandTypeSpi.saveType(
override fun saveOrUpdateType(
date: LocalDate,
type: DirectorType,
) {
val existType = queryTypeSpi.queryTypeByDate(date)

existType?.let {
commandTypeSpi.saveType(
it.changeType(
type,
),
)
} ?: commandTypeSpi.saveType(
Type(
date = date,
type = type,
),
)
}

override fun updateType(date: LocalDate, type: DirectorType) {
val currentType = queryTypeSpi.queryTypeByDate(date)
?: throw TypeNotFoundException
commandTypeSpi.saveType(
currentType.changeType(date, type),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ data class Type(

val type: DirectorType,
) {
fun changeType(date: LocalDate, type: DirectorType): Type {
fun changeType(type: DirectorType): Type {
return copy(
date = date,
type = type,
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.pickdsm.pickserverspring.common.error

import com.pickdsm.pickserverspring.common.error.ErrorProperty
import org.springframework.dao.DataIntegrityViolationException
import org.springframework.validation.BindingResult
import org.springframework.validation.FieldError
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.pickdsm.pickserverspring.common.error

import com.pickdsm.pickserverspring.common.error.ErrorProperty

enum class GlobalErrorCode(
private val status: Int,
private val message: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,7 @@ class AdminWebAdapter(
@RequestParam
type: DirectorType,
) {
adminApi.saveType(date, type)
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@PatchMapping("/type")
fun updateType(
@RequestParam
@DateTimeFormat(pattern = "yyyy-MM-dd")
date: LocalDate,
@RequestParam
type: DirectorType,
) {
adminApi.updateType(date, type)
adminApi.saveOrUpdateType(date, type)
}

@PostMapping("/director")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class ApplicationEntity(
@ColumnDefault("false")
val isReturn: Boolean,

) : BaseUUIDEntity(id)
) : BaseUUIDEntity(id)
Loading