diff --git a/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupFacade.kt b/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupFacade.kt index f95d16c..90f74eb 100644 --- a/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupFacade.kt +++ b/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupFacade.kt @@ -79,6 +79,10 @@ class GroupFacade( false -> withdrawGroupUser(group, uid, groupUser) } } + + txTemplates.writer.executes { + groupUserScoreService.deleteAllByUid(uid) + } } private suspend fun withdrawGroupOwner(uid: Long, group: Group, groupUser: GroupUser) { @@ -100,7 +104,7 @@ class GroupFacade( groupService.saveSync(succeedGroup) } } - + groupUserService.delete(groupUser) } } @@ -234,6 +238,7 @@ class GroupFacade( txTemplates.writer.executesOrNull { groupUserService.deleteSync(groupUserId) groupService.saveSync(group.apply { this.userCount -= 1 }) + groupUserScoreService.deleteAllByUid(user.uid) } } diff --git a/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupService.kt b/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupService.kt index 214b05f..48c95de 100644 --- a/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupService.kt +++ b/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupService.kt @@ -16,6 +16,7 @@ import org.springframework.data.domain.Page import org.springframework.data.domain.Pageable import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional @Service class GroupService( @@ -66,6 +67,7 @@ class GroupService( groupRepository.deleteById(id) } + @Transactional fun saveSync(group: Group): Group { return groupRepository.save(group) } diff --git a/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupUserScoreService.kt b/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupUserScoreService.kt index 93478e0..cb765a1 100644 --- a/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupUserScoreService.kt +++ b/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupUserScoreService.kt @@ -92,4 +92,9 @@ class GroupUserScoreService( fun deleteAllByModifiedAtBeforeSync(modifiedAt: LocalDateTime) { return groupUserScoreRepository.deleteAllByModifiedAtBefore(modifiedAt) } + + @Transactional + fun deleteAllByUid(uid: Long) { + groupUserScoreRepository.deleteAllByUid(uid) + } }