Skip to content

Commit

Permalink
๐Ÿ”€ :: (#255) ํƒ€์ž… ๋ณ€๊ฒฝ API ์˜ค๋ฅ˜ ์ˆ˜์ • (#124)
Browse files Browse the repository at this point in the history
* โ™ป๏ธ :: ๋ฉ”์†Œ๋“œ๋ช… ๋ณ€๊ฒฝ ๋ฐ ํƒ€์ž…์ด ์žˆ์„ ์‹œ ํƒ€์ž… ์ˆ˜์ •์œผ๋กœ ๋ณ€๊ฒฝ

* โ™ป๏ธ :: ๋ฉ”์†Œ๋“œ๋ช… ๋ณ€๊ฒฝ

* โ™ป๏ธ :: ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๋ฉ”์†Œ๋“œ ์ œ๊ฑฐ

* โ™ป๏ธ :: letํ•จ์ˆ˜๋กœ ๋ณ€๊ฒฝ

* โ™ป๏ธ :: klint ํ•ด๊ฒฐ

* โ™ป๏ธ :: ktlint ํ•ด๊ฒฐ

* โ™ป๏ธ :: ktlint ํ•ด๊ฒฐ

* โ™ป๏ธ :: ์ค„๋ฐ”๊ฟˆ ์ œ๊ฑฐ

* โ™ป๏ธ :: ktlint ํ•ด๊ฒฐ
  • Loading branch information
alsco39 authored Jan 17, 2024
1 parent f0dc850 commit 0b43eb5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 32 deletions.
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)

0 comments on commit 0b43eb5

Please sign in to comment.