Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
meltapplee committed Oct 31, 2024
2 parents af40bd6 + a3240fc commit a766b79
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,33 @@ class ChangeClassroomStatusService(
deleteClassRoomPort.deleteByUserId(classroom.userId)
}
eventPublisher.publishEvent(ChangeStatusRequest(this, request.idList))
}
} else {
val update = mutableListOf<Classroom>()
val updateAttendanceList = mutableListOf<Attendance>()

val update = mutableListOf<Classroom>()
val updateAttendanceList = mutableListOf<Attendance>()
request.idList.forEach { id ->
val classroom = queryClassroomPort.findByUserId(id) ?: throw ClassroomNotFoundException

request.idList.forEach { id ->
val classroom = queryClassroomPort.findByUserId(id) ?: throw ClassroomNotFoundException
val updatedClassroom = classroom.copy(status = OK)
update.add(updatedClassroom)

val updatedClassroom = classroom.copy(status = OK)
update.add(updatedClassroom)
val updatedAttendance = queryAttendancePort.findByUserId(classroom.userId)?.run {
copy(
period6 = getStatus(classroom, period6, 6),
period7 = getStatus(classroom, period7, 7),
period8 = getStatus(classroom, period8, 8),
period9 = getStatus(classroom, period9, 9),
period10 = getStatus(classroom, period10, 10)
)
} ?: throw UserNotFoundException

val updatedAttendance = queryAttendancePort.findByUserId(classroom.userId)?.run {
copy(
period6 = getStatus(classroom, period6, 6),
period7 = getStatus(classroom, period7, 7),
period8 = getStatus(classroom, period8, 8),
period9 = getStatus(classroom, period9, 9),
period10 = getStatus(classroom, period10, 10)
)
} ?: throw UserNotFoundException
updateAttendanceList.add(updatedAttendance)
}

updateAttendanceList.add(updatedAttendance)
saveClassRoomPort.saveAll(update)
saveAttendancePort.saveAll(updateAttendanceList)
eventPublisher.publishEvent(ChangeStatusRequest(this, updateAttendanceList.map { it.userId }))
}

saveClassRoomPort.saveAll(update)
saveAttendancePort.saveAll(updateAttendanceList)
eventPublisher.publishEvent(ChangeStatusRequest(this, updateAttendanceList.map { it.userId }))
}

private fun getStatus(
Expand Down

0 comments on commit a766b79

Please sign in to comment.