-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
41 deletions.
There are no files selected for viewing
41 changes: 0 additions & 41 deletions
41
src/main/java/com/smeme/server/controller/ScheduleController.java
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/main/java/com/smeme/server/scheduler/DiaryScheduler.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,19 @@ | ||
package com.smeme.server.scheduler; | ||
|
||
import com.smeme.server.service.DiaryService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@EnableScheduling | ||
@RequiredArgsConstructor | ||
public class DiaryScheduler { | ||
private final DiaryService diaryService; | ||
|
||
@Scheduled(cron = "0 0 0 * * *") | ||
public void deleteExpiredDiaries() { | ||
diaryService.deleteExpiredDiary(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/smeme/server/scheduler/MessageScheduler.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,24 @@ | ||
package com.smeme.server.scheduler; | ||
|
||
import com.smeme.server.config.ValueConfig; | ||
import com.smeme.server.service.MessageService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Component | ||
@EnableScheduling | ||
@RequiredArgsConstructor | ||
public class MessageScheduler { | ||
private final MessageService messageService; | ||
private final ValueConfig valueConfig; | ||
|
||
@Scheduled(cron = "${fcm.cron_expression}") | ||
public void pushMessage() throws InterruptedException { | ||
Thread.sleep(1000); | ||
messageService.pushMessageForTrainingTime(LocalDateTime.now(), valueConfig.getMESSAGE_TITLE(), valueConfig.getMESSAGE_BODY()); | ||
} | ||
} |