Skip to content

Commit

Permalink
chore: (#733) 메서드, 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
zios0707 committed Sep 19, 2024
1 parent 0cdc882 commit bd5743d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ data class VolunteerApplication(

val approved: Boolean,
) {
fun checkCancelable(approved: Boolean) {
fun checkIsNotApproved() {
if (approved) {
throw VolunteerApplicationAlreadyAssigned
}
}

fun checkExcludable(approved: Boolean) {
fun checkIsApproved() {
if (!approved) {
throw VolunteerApplicationNotAssigned
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ApproveVolunteerApplicationUseCase(

val currentVolunteerApplication = volunteerService.getVolunteerApplicationById(volunteerApplicationId)

currentVolunteerApplication.checkIsNotApproved()

volunteerService.saveVolunteerApplication(
currentVolunteerApplication.copy(
approved = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class ExcludeVolunteerApplicationUseCase(
fun execute(volunteerApplicationId: UUID) {
val currentVolunteerApplication = volunteerService.getVolunteerApplicationById(volunteerApplicationId)

currentVolunteerApplication.apply {
checkExcludable(currentVolunteerApplication.approved)
}
currentVolunteerApplication.checkIsApproved()

volunteerService.deleteVolunteerApplication(currentVolunteerApplication)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class RejectVolunteerApplicationUseCase(
fun execute(volunteerApplicationId: UUID) {
val currentVolunteerApplication = volunteerService.getVolunteerApplicationById(volunteerApplicationId)

currentVolunteerApplication.apply {
checkCancelable(currentVolunteerApplication.approved)
}
currentVolunteerApplication.checkIsNotApproved()

volunteerService.deleteVolunteerApplication(currentVolunteerApplication)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ class UnapplyVolunteerUseCase(
fun execute(volunteerApplicationId: UUID) {
val volunteer = volunteerService.getVolunteerApplicationById(volunteerApplicationId)

volunteerService.getVolunteerApplicationById(volunteerApplicationId)
.apply {
checkCancelable(volunteer.approved)
}
volunteer.checkIsNotApproved()

volunteerService.deleteVolunteerApplication(volunteer)
}
Expand Down

0 comments on commit bd5743d

Please sign in to comment.