1
1
package com.hero.alignlab.event.listener
2
2
3
- import com.hero.alignlab.config.database.TransactionTemplates
4
- import com.hero.alignlab.domain.discussion.infrastructure.DiscussionCommentRepository
5
- import com.hero.alignlab.domain.discussion.infrastructure.DiscussionRepository
3
+ import com.hero.alignlab.domain.group.application.GroupFacade
6
4
import com.hero.alignlab.domain.group.infrastructure.GroupRepository
7
- import com.hero.alignlab.domain.group.infrastructure.GroupUserRepository
8
5
import com.hero.alignlab.domain.notification.infrastructure.PoseNotificationRepository
6
+ import com.hero.alignlab.domain.pose.infrastructure.*
9
7
import com.hero.alignlab.event.model.WithdrawEvent
10
8
import kotlinx.coroutines.CoroutineScope
11
9
import kotlinx.coroutines.Dispatchers
@@ -15,18 +13,29 @@ import org.springframework.transaction.event.TransactionalEventListener
15
13
16
14
@Component
17
15
class WithdrawEventListener (
18
- private val txTemplates : TransactionTemplates ,
19
- private val discussionRepository : DiscussionRepository ,
16
+ /* * 탈퇴 회원이 그룹장인 경우 승계 작업 필요. */
17
+ private val groupFacade : GroupFacade ,
20
18
private val groupRepository : GroupRepository ,
21
- private val groupUserRepository : GroupUserRepository ,
19
+
20
+ /* * 자세 데이터, 탈퇴회원이 있더라도 문제 없음. */
21
+ private val poseCountRepository : PoseCountRepository ,
22
+ private val poseSnapshotRepository : PoseSnapshotRepository ,
23
+ private val poseKeyPointSnapshotRepository : PoseKeyPointSnapshotRepository ,
24
+ private val poseLayoutRepository : PoseLayoutRepository ,
25
+ private val poseLayoutPointRepository : PoseLayoutPointRepository ,
22
26
private val poseNotificationRepository : PoseNotificationRepository ,
23
- private val discussionCommentRepository : DiscussionCommentRepository ,
24
27
) {
28
+ /* *
29
+ * 현상황에서 그룹 승계 작업만 원활히 진행되면, 그외 데이터의 경우 탈퇴로 인한 문제는 발생하지 않는다.
30
+ */
25
31
@TransactionalEventListener
26
32
fun handle (event : WithdrawEvent ) {
33
+ /* * 그룹 승계 및 탈퇴 */
27
34
CoroutineScope (Dispatchers .IO ).launch {
28
- txTemplates.writer.executeWithoutResult {
29
- // TODO: 회원 탈퇴 로직 필요.
35
+ val group = groupRepository.findByOwnerUid(event.uid)
36
+
37
+ if (group != null ) {
38
+ groupFacade.withdraw(group.id, event.uid)
30
39
}
31
40
}
32
41
}
0 commit comments