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 b58bb54..bca8f25 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 @@ -89,6 +89,7 @@ class GroupFacade( false -> { val succeedGroup = group.apply { this.ownerUid = groupUser.uid + this.userCount -= 1 } groupService.saveSync(succeedGroup) } @@ -210,10 +211,13 @@ class GroupFacade( val groupUser = groupUserService.findByIdOrNull(groupUserId) ?: throw NotFoundException(ErrorCode.NOT_FOUND_USER_ERROR) - groupService.findByIdAndOwnerUid(groupUser.groupId, user.uid) + val group = groupService.findByIdAndOwnerUid(groupUser.groupId, user.uid) ?: throw NotFoundException(ErrorCode.NOT_FOUND_USER_ERROR) - groupUserService.deleteSync(groupUserId) + txTemplates.writer.executesOrNull { + groupUserService.deleteSync(groupUserId) + groupService.saveSync(group.apply { this.userCount -= 1 }) + } } suspend fun checkGroupRegisterRequest(user: AuthUser, request: CheckGroupRegisterRequest) { diff --git a/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupUserService.kt b/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupUserService.kt index 751c320..b889baf 100644 --- a/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupUserService.kt +++ b/src/main/kotlin/com/hero/alignlab/domain/group/application/GroupUserService.kt @@ -95,6 +95,7 @@ class GroupUserService( } } + @Transactional fun deleteSync(groupUserId: Long) { groupUserRepository.deleteById(groupUserId) }