From 963e9be1ca1aa4948a9226b0fd83762306be0f9a Mon Sep 17 00:00:00 2001 From: DongGeon0908 Date: Wed, 4 Sep 2024 00:41:05 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B7=B8=EB=A3=B9=20=EC=8A=A4=EC=BD=94?= =?UTF-8?q?=EC=96=B4=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 --- .../event/listener/PoseSnapshotListener.kt | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/hero/alignlab/event/listener/PoseSnapshotListener.kt b/src/main/kotlin/com/hero/alignlab/event/listener/PoseSnapshotListener.kt index 4ea9ccf..1efe53d 100644 --- a/src/main/kotlin/com/hero/alignlab/event/listener/PoseSnapshotListener.kt +++ b/src/main/kotlin/com/hero/alignlab/event/listener/PoseSnapshotListener.kt @@ -4,6 +4,7 @@ import com.hero.alignlab.common.extension.coExecuteOrNull import com.hero.alignlab.config.database.TransactionTemplates import com.hero.alignlab.domain.group.application.GroupUserScoreService import com.hero.alignlab.domain.group.application.GroupUserService +import com.hero.alignlab.domain.group.domain.GroupUserScore import com.hero.alignlab.domain.pose.application.PoseCountService import com.hero.alignlab.domain.pose.application.PoseKeyPointSnapshotService import com.hero.alignlab.domain.pose.domain.PoseCount @@ -55,15 +56,26 @@ class PoseSnapshotListener( .values .sum() + /** group score 처리 */ val groupUser = groupUserService.findByUid(event.poseSnapshot.uid) - val groupUserScore = groupUserScoreService.findByUidOrNull(event.poseSnapshot.uid) + val updatedGroupUserScore = when (groupUser == null) { + true -> null + false -> { + val groupUserScore = groupUserScoreService.findByUidOrNull(event.poseSnapshot.uid) - val updatedGroupUserScore = when (groupUser != null && groupUserScore != null) { - true -> groupUserScore.apply { - this.score = score - } + when (groupUserScore != null) { + true -> groupUserScore.apply { + this.score = score + } - false -> null + false -> GroupUserScore( + groupId = groupUser.groupId, + groupUserId = groupUser.id, + uid = groupUser.uid, + score = score + ) + } + } } txTemplates.writer.coExecuteOrNull {