-
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.
[FEATURE] 탈퇴 유저 정보 삭제 스케쥴링 구현 (#152)
- Loading branch information
1 parent
9503786
commit 6d79596
Showing
10 changed files
with
96 additions
and
3 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
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
52 changes: 52 additions & 0 deletions
52
Domain/src/main/java/tify/server/domain/scheduler/user/UserResignScheduler.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,52 @@ | ||
package tify.server.domain.scheduler.user; | ||
|
||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import tify.server.domain.domains.question.repository.AnswerReportRepository; | ||
import tify.server.domain.domains.question.repository.AnswerRepository; | ||
import tify.server.domain.domains.question.repository.FavorAnswerRepository; | ||
import tify.server.domain.domains.question.repository.KnockRepository; | ||
import tify.server.domain.domains.user.domain.User; | ||
import tify.server.domain.domains.user.repository.NeighborRepository; | ||
import tify.server.domain.domains.user.repository.UserBlockRepository; | ||
import tify.server.domain.domains.user.repository.UserReportRepository; | ||
import tify.server.domain.domains.user.repository.UserRepository; | ||
import tify.server.domain.domains.user.service.UserDomainService; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class UserResignScheduler { | ||
|
||
private final UserDomainService userDomainService; | ||
|
||
private final UserRepository userRepository; | ||
private final AnswerRepository answerRepository; | ||
private final AnswerReportRepository answerReportRepository; | ||
private final FavorAnswerRepository favorAnswerRepository; | ||
private final KnockRepository knockRepository; | ||
private final NeighborRepository neighborRepository; | ||
private final UserBlockRepository userBlockRepository; | ||
private final UserReportRepository userReportRepository; | ||
|
||
@Transactional | ||
@Scheduled(cron = "0 0 0 * * *", zone = "Asia/Seoul") | ||
public void deleteResignedUsers() { | ||
List<User> resignedUserList = userDomainService.getResignedUsers(); | ||
resignedUserList.forEach( | ||
user -> { | ||
answerRepository.deleteAllByUserId(user.getId()); | ||
answerReportRepository.deleteAllByReportUserId(user.getId()); | ||
favorAnswerRepository.deleteAllByUserId(user.getId()); | ||
knockRepository.deleteAllByUserIdOrKnockedUserId(user.getId(), user.getId()); | ||
neighborRepository.deleteAllByFromUserIdOrToUserId(user.getId(), user.getId()); | ||
userBlockRepository.deleteAllByFromUserIdOrToUserId(user.getId(), user.getId()); | ||
userReportRepository.deleteAllByFromUserIdOrToUserId( | ||
user.getId(), user.getId()); | ||
userRepository.delete(user); | ||
}); | ||
} | ||
} |