-
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
15 changed files
with
155 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.khumu.alimi.data; | ||
|
||
public enum ResourceKind { | ||
comment, article, announcement, study_article, haksa_schedule | ||
user, comment, article, announcement, study_article, haksa_schedule | ||
} |
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,41 @@ | ||
package com.khumu.alimi.data.dto; | ||
|
||
import lombok.*; | ||
|
||
/** | ||
* 이벤트 메시지로 전달받는 유저 정보. 이 중 필요한 필드만 사용한다. | ||
{ | ||
"last_login": null, | ||
"is_active": true, | ||
"date_joined": "2021-12-03T03:27:35.493", | ||
"username": "jinsu.dev", | ||
"kind": "guest", | ||
"nickname": "\\uac1c\\ubc1c\\ud558\\ub294 \\ud638\\ub791\\uc774", | ||
"student_number": "2000123123", | ||
"department": "\\ud559\\uacfc \\ubbf8\\uc124\\uc815", | ||
"created_at": "2021-12-03T03:27:35.493", | ||
"status": "deleted", | ||
"is_superuser": false, | ||
"profile_image": null, | ||
"info21_authenticated_at": null, | ||
"groups": [], | ||
"user_permissions": [] | ||
} | ||
*/ | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
@Builder | ||
public class KhumuUserDto { | ||
private String username; | ||
|
||
@Override | ||
public String toString() { | ||
return "KhumuUserDto{" + | ||
"username='" + username + '\'' + | ||
'}'; | ||
} | ||
} | ||
|
||
|
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
45 changes: 45 additions & 0 deletions
45
src/main/java/com/khumu/alimi/service/DeleteUserService.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,45 @@ | ||
package com.khumu.alimi.service; | ||
|
||
import com.khumu.alimi.data.dto.KhumuUserDto; | ||
import com.khumu.alimi.data.entity.PushDevice; | ||
import com.khumu.alimi.data.entity.ResourceNotificationSubscription; | ||
import com.khumu.alimi.repository.NotificationRepository; | ||
import com.khumu.alimi.repository.PushDeviceRepository; | ||
import com.khumu.alimi.repository.ResourceNotificationSubscriptionRepository; | ||
import com.khumu.alimi.service.notification.NotificationService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* 게시물 관련된 이벤트가 발생했을 때 무슨 작업을 수행할 것인지. | ||
*/ | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Service | ||
public class DeleteUserService { | ||
private final ResourceNotificationSubscriptionRepository resourceNotificationSubscriptionRepository; | ||
private final PushDeviceRepository pushDeviceRepository; | ||
|
||
@Transactional | ||
// 유저와 관련된 정보들을 삭제합니다. | ||
public void delete(KhumuUserDto user) { | ||
log.info(user + "와 관련된 정보를 삭제합니다."); | ||
if (user == null || user.getUsername() == null) { | ||
log.error("유저 정보가 존재하지 않습니다. " + user); | ||
throw new RuntimeException("유저 정보가 존재하지 않음"); | ||
} else { | ||
List<PushDevice> devices = pushDeviceRepository.findAllByUser(user.getUsername()); | ||
for (PushDevice device : devices) { | ||
// @Transactional 있어야 함. | ||
device.deleteUserInfo(); | ||
} | ||
|
||
List<ResourceNotificationSubscription> subscriptions = resourceNotificationSubscriptionRepository.findAllBySubscriber(user.getUsername()); | ||
resourceNotificationSubscriptionRepository.deleteAll(subscriptions); | ||
} | ||
} | ||
} |
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