From 3e574d8ae080019e44cd5dfff70b790c17b9109d Mon Sep 17 00:00:00 2001 From: DongGeon0908 Date: Wed, 4 Sep 2024 21:05:52 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B7=B8=EB=A3=B9=EC=9B=90=20=EC=88=98?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=B2=98=EB=A6=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hero/alignlab/domain/group/application/GroupFacade.kt | 8 ++++++-- .../alignlab/domain/group/application/GroupUserService.kt | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) 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) }