-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/DSM-PICK/PICK2024_SERVER …
…into develop
- Loading branch information
Showing
7 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/dsm/pick2024/domain/attendance/port/in/ResetAttendanceUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package dsm.pick2024.domain.attendance.port.`in` | ||
|
||
interface ResetAttendanceUseCase { | ||
fun reset() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/dsm/pick2024/domain/attendance/port/out/FindAllAttendancePort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package dsm.pick2024.domain.attendance.port.out | ||
|
||
import dsm.pick2024.domain.attendance.domain.Attendance | ||
|
||
interface FindAllAttendancePort { | ||
fun findAll(): List<Attendance> | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/dsm/pick2024/domain/attendance/service/ResetAttendanceService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dsm.pick2024.domain.attendance.service | ||
|
||
import dsm.pick2024.domain.afterschool.enums.Status | ||
import dsm.pick2024.domain.attendance.domain.Attendance | ||
import dsm.pick2024.domain.attendance.port.`in`.ResetAttendanceUseCase | ||
import dsm.pick2024.domain.attendance.port.out.FindAllAttendancePort | ||
import dsm.pick2024.domain.attendance.port.out.SaveAll | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class ResetAttendanceService( | ||
private val findAllAttendancePort: FindAllAttendancePort, | ||
private val saveAll: SaveAll | ||
) : ResetAttendanceUseCase { | ||
override fun reset() { | ||
val allStudent = findAllAttendancePort.findAll() | ||
val update = mutableListOf<Attendance>() | ||
|
||
allStudent.map { attendance -> | ||
val updatedAttendance = | ||
attendance.copy( | ||
period6 = getStatus(attendance.period6), | ||
period7 = getStatus(attendance.period7), | ||
period8 = getStatus(attendance.period8), | ||
period9 = getStatus(attendance.period9), | ||
period10 = getStatus(attendance.period10) | ||
) | ||
update.add(updatedAttendance) | ||
} | ||
|
||
saveAll.saveAll(update) | ||
} | ||
|
||
private fun getStatus(currentStatus: Status) = | ||
when (currentStatus) { | ||
Status.PICNIC, Status.EMPLOYMENT -> currentStatus | ||
else -> Status.ATTENDANCE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters