Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rudeh2926 committed Apr 10, 2024
2 parents 8bee1a0 + 8941afc commit 9b30184
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/git-action-stag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
JWT_REFRESH_EXP=36000000
JWT_HEADER=Authorization
JWT_PREFIX=Bearer
DB_URL=${{ secrets.DB_URL }}
DB_USERNAME=${{ secrets.STAG_DB_USERNAME }}
DB_URL=${{ secrets.STAG_DB_URL }}
DB_USERNAME=${{ secrets.DB_USERNAME }}
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
REDIS_HOST=${{ secrets.REDIS_HOST }}
REDIS_PORT=${{ secrets.REDIS_PORT }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class AttendancePersistenceAdapter(
override fun findByUserId(userId: UUID) =
attendanceJpaRepository.findByUserId(userId).let { attendanceMapper.toDomain(it) }

override fun findAll() = attendanceJpaRepository.findAll().map { attendanceMapper.toDomain(it) }

override fun findByGradeAndClassNum(
grade: Int,
classNum: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ interface AttendanceRepository : Repository<AttendanceJpaEntity, UUID> {
fun saveAll(entity: Iterable<AttendanceJpaEntity>)

fun findByUserId(userId: UUID): AttendanceJpaEntity

fun findAll(): List<AttendanceJpaEntity>
}
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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ interface AttendancePort :
SaveAll,
FindByUserIdPort,
QueryClassAttendancePort,
QueryClubAttendancePort
QueryClubAttendancePort,
FindAllAttendancePort
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>
}
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
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dsm.pick2024.infrastructure.schedule

import dsm.pick2024.domain.application.port.out.DeleteAllApplicationPort
import dsm.pick2024.domain.attendance.port.`in`.ResetAttendanceUseCase
import dsm.pick2024.domain.classroom.port.out.DeleteAllClassRoomPort
import dsm.pick2024.domain.earlyreturn.port.out.DeleteAllEarlyReturnPort
import dsm.pick2024.domain.meal.port.`in`.MealUseCase
Expand All @@ -12,7 +13,8 @@ class ScheduleService(
private val deleteAllClassRoomPort: DeleteAllClassRoomPort,
private val deleteAllEarlyReturnPort: DeleteAllEarlyReturnPort,
private val deleteAllApplicationPort: DeleteAllApplicationPort,
private val mealUseCase: MealUseCase
private val mealUseCase: MealUseCase,
private val resetAttendanceUseCase: ResetAttendanceUseCase
) {
@Scheduled(cron = "0 30 20 * * ?", zone = "Asia/Seoul")
fun deleteTable() {
Expand All @@ -25,4 +27,9 @@ class ScheduleService(
fun mealSave() {
mealUseCase.saveNeisInfoToDatabase()
}

@Scheduled(cron = "0 00 21 * * ?", zone = "Asia/Seoul")
fun resetTable() {
resetAttendanceUseCase.reset()
}
}

0 comments on commit 9b30184

Please sign in to comment.