Skip to content

Commit

Permalink
fix: 그룹 탈퇴 및 내보내기 진행시 score 정보도 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Sep 25, 2024
1 parent 4ad6baa commit 05ec593
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -100,7 +104,7 @@ class GroupFacade(
groupService.saveSync(succeedGroup)
}
}

groupUserService.delete(groupUser)
}
}
Expand Down Expand Up @@ -234,6 +238,7 @@ class GroupFacade(
txTemplates.writer.executesOrNull {
groupUserService.deleteSync(groupUserId)
groupService.saveSync(group.apply { this.userCount -= 1 })
groupUserScoreService.deleteAllByUid(user.uid)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -66,6 +67,7 @@ class GroupService(
groupRepository.deleteById(id)
}

@Transactional
fun saveSync(group: Group): Group {
return groupRepository.save(group)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,9 @@ class GroupUserScoreService(
fun deleteAllByModifiedAtBeforeSync(modifiedAt: LocalDateTime) {
return groupUserScoreRepository.deleteAllByModifiedAtBefore(modifiedAt)
}

@Transactional
fun deleteAllByUid(uid: Long) {
groupUserScoreRepository.deleteAllByUid(uid)
}
}

0 comments on commit 05ec593

Please sign in to comment.