diff --git a/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/service/PreviewService.java b/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/service/PreviewService.java index b00a4af2..ca543e7f 100644 --- a/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/service/PreviewService.java +++ b/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/service/PreviewService.java @@ -25,9 +25,30 @@ public EventUser preview(PreviewRequest previewRequest, Model model) { throw new DrawingEventNotParticipantException(); } - double scoreGame1 = Double.parseDouble((String) eventUser.getScores().get("1_game_score")); + double scoreGame1 = getGameScore(eventUser.getScores().get("1_game_score")); model.addAttribute("score", String.format("%.1f", scoreGame1)); return eventUser; } + + private double getGameScore(Object rawGameScore) { + double scoreGame1; + if (rawGameScore != null) { + if (rawGameScore instanceof String) { + try { + scoreGame1 = Double.parseDouble((String) rawGameScore); + } catch (NumberFormatException e) { + scoreGame1 = 0.0; + } + } else if (rawGameScore instanceof Number) { + scoreGame1 = ((Number) rawGameScore).doubleValue(); + } else { + scoreGame1 = 0.0; + } + } else { + scoreGame1 = 0.0; + } + + return scoreGame1; + } }