-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from Modagbul/feat/alarm_minsu
매일 자정에 7일 전 알림 삭제하는 스케줄러 추가
- Loading branch information
Showing
5 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/com/moing/backend/domain/history/application/service/CleanupUseCase.java
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,25 @@ | ||
package com.moing.backend.domain.history.application.service; | ||
|
||
import com.moing.backend.domain.history.domain.service.AlarmHistoryDeleteService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CleanupUseCase { | ||
|
||
private final AlarmHistoryDeleteService alarmHistoryDeleteService; | ||
|
||
@Scheduled(cron = "0 0 0 * * ?") | ||
public void cleanupOldAlarmHistories() { | ||
CompletableFuture.runAsync(() -> { | ||
LocalDateTime oneWeekAgo = LocalDateTime.now().minusWeeks(1); | ||
alarmHistoryDeleteService.deleteByCreatedDateBefore(oneWeekAgo); | ||
}); | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/moing/backend/domain/history/domain/service/AlarmHistoryDeleteService.java
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,20 @@ | ||
package com.moing.backend.domain.history.domain.service; | ||
|
||
import com.moing.backend.domain.history.domain.repository.AlarmHistoryRepository; | ||
import com.moing.backend.global.annotation.DomainService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@DomainService | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class AlarmHistoryDeleteService { | ||
|
||
private final AlarmHistoryRepository alarmHistoryRepository; | ||
|
||
public void deleteByCreatedDateBefore(LocalDateTime oneWeekAgo) { | ||
alarmHistoryRepository.deleteByCreatedDateBefore(oneWeekAgo); | ||
} | ||
} |
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