-
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.
* feat: spring schefuler config 등록 * feat: 스케줄러를 이용해 apply엔티티의 soft-delete 적용 * feat: entity delete scheduler 통합 * feat: deletable entity에 delete query 추가 (통합예정) )
- Loading branch information
지훈
authored
Jan 24, 2022
1 parent
c67c368
commit c6d2a04
Showing
12 changed files
with
117 additions
and
0 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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/yapp/project/common/Scheduler/EntityDeletionScheduler.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,47 @@ | ||
package com.yapp.project.common.Scheduler; | ||
|
||
import com.yapp.project.apply.service.ApplyService; | ||
import com.yapp.project.member.service.MemberService; | ||
import com.yapp.project.post.service.PostService; | ||
import com.yapp.project.review.service.CodeReviewHistoryService; | ||
import com.yapp.project.review.service.TextReviewHistoryService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Component | ||
public class EntityDeletionScheduler { | ||
private final ApplyService applyService; | ||
private final MemberService memberService; | ||
private final PostService postService; | ||
private final CodeReviewHistoryService codeReviewHistoryService; | ||
private final TextReviewHistoryService textReviewHistoryService; | ||
|
||
/** | ||
* cron : 초 분 시 일 월 년 | ||
* 매일 자정(00:00:00)시에 스케줄러 실행 | ||
*/ | ||
@Scheduled(cron = "0 0 0 * * *", zone = "Asia/Seoul") | ||
public void deletePermanently() { | ||
LocalDate today = LocalDate.now(); | ||
LocalDateTime baseDeletionTime = today.minusMonths(1).atStartOfDay(); | ||
|
||
applyService.deleteAllExpiredDate(baseDeletionTime); | ||
|
||
memberService.deleteAllExpiredDate(baseDeletionTime); | ||
|
||
postService.deleteAllExpiredDate(baseDeletionTime); | ||
|
||
codeReviewHistoryService.deleteAllExpiredDate(baseDeletionTime); | ||
|
||
textReviewHistoryService.deleteAllExpiredDate(baseDeletionTime); | ||
|
||
log.info("entity deletion completed in {} / base deletion date: {}", today, baseDeletionTime); | ||
} | ||
} |
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,9 @@ | ||
package com.yapp.project.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
@Configuration | ||
@EnableScheduling | ||
public class SchedulerConfig { | ||
} |
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
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
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
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