From 8564739deffee6d98f9cf90d6cafaf00535bb481 Mon Sep 17 00:00:00 2001 From: mjmj Date: Sun, 25 Aug 2024 11:08:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=B5=9C=EC=A2=85=20=EB=B2=84=EA=B7=B8?= =?UTF-8?q?=20=ED=94=BD=EC=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 21 ++++++++++++++----- .../drawing/controller/PreviewController.java | 3 +-- .../service/DrawingLotteryService.java | 6 +++--- .../drawing/service/PreviewService.java | 6 +++++- src/main/resources/templates/preview.html | 1 + 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 92208f9f..d00b272a 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,12 @@ repositories { mavenCentral() } +dependencyManagement { + imports { + mavenBom "com.amazonaws:aws-java-sdk-bom:1.12.472" + } +} + dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-aop' @@ -31,8 +37,16 @@ dependencies { // template engine implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + // Json + implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.2' + implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.2' + implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.3' + implementation 'org.json:json:20210307' + // aws - implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' + implementation 'com.amazonaws:aws-java-sdk-s3' + implementation 'com.amazonaws:aws-java-sdk-sts' + // db implementation 'org.springframework.boot:spring-boot-starter-data-jpa' @@ -55,9 +69,6 @@ dependencies { // Apache Commons implementation 'org.apache.commons:commons-lang3:3.12.0' - // Json - implementation 'org.json:json:20210307' - // Actuator implementation 'org.springframework.boot:spring-boot-starter-actuator' @@ -73,4 +84,4 @@ dependencies { tasks.named('test') { jvmArgs = ["-Dspring.profiles.active=test"] useJUnitPlatform() -} +} \ No newline at end of file diff --git a/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/controller/PreviewController.java b/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/controller/PreviewController.java index 919d0280..dd6f5960 100644 --- a/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/controller/PreviewController.java +++ b/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/controller/PreviewController.java @@ -45,11 +45,10 @@ public String preview( @Validated PreviewRequest previewRequest, Model model ) { - EventUser eventUser = previewService.preview(previewRequest); + EventUser eventUser = previewService.preview(previewRequest, model); model.addAttribute("resultImgUrl", eventUser.getResultImgUrl()); model.addAttribute("name", eventUser.getUser().getName()); - model.addAttribute("score", eventUser.getGameScore()); model.addAttribute("apiUrl", baseUrl); model.addAttribute("ogUrl", baseUrl + "/api/v1/preview/" + previewRequest.getSharedUrl()); model.addAttribute("sharedUrl", previewRequest.getSharedUrl()); diff --git a/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/service/DrawingLotteryService.java b/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/service/DrawingLotteryService.java index f892b2ff..85fb6e78 100644 --- a/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/service/DrawingLotteryService.java +++ b/src/main/java/com/hyundai/softeer/backend/domain/lottery/drawing/service/DrawingLotteryService.java @@ -237,7 +237,7 @@ public void saveDrawImage(MultipartFile file, Long eventId, User authenticatedUs EventUser eventUser = eventUserRepository.findByUserIdAndSubEventId(authenticatedUser.getId(), subEvent.getId()) .orElseThrow(() -> new EventUserNotFoundException()); - String fileName = createFileName(file.getOriginalFilename()); + String fileName = createFileName(); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(file.getSize()); metadata.setContentType(file.getContentType()); @@ -253,7 +253,7 @@ public void saveDrawImage(MultipartFile file, Long eventId, User authenticatedUs eventUser.setResultImgUrl(fileUrl); } - private String createFileName(String originalFileName) { - return UUID.randomUUID().toString() + "-" + originalFileName; + private String createFileName() { + return UUID.randomUUID().toString(); } } 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 c6dc05be..b00a4af2 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 @@ -7,6 +7,7 @@ import com.hyundai.softeer.backend.domain.lottery.drawing.exception.DrawingEventNotParticipantException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.ui.Model; @Service @RequiredArgsConstructor @@ -14,7 +15,7 @@ public class PreviewService { private final EventUserRepository eventUserRepository; - public EventUser preview(PreviewRequest previewRequest) { + public EventUser preview(PreviewRequest previewRequest, Model model) { String sharedUrl = previewRequest.getSharedUrl(); EventUser eventUser = eventUserRepository.findBySharedUrl(sharedUrl) @@ -24,6 +25,9 @@ public EventUser preview(PreviewRequest previewRequest) { throw new DrawingEventNotParticipantException(); } + double scoreGame1 = Double.parseDouble((String) eventUser.getScores().get("1_game_score")); + model.addAttribute("score", String.format("%.1f", scoreGame1)); + return eventUser; } } diff --git a/src/main/resources/templates/preview.html b/src/main/resources/templates/preview.html index 06cdcee3..f07e3e76 100644 --- a/src/main/resources/templates/preview.html +++ b/src/main/resources/templates/preview.html @@ -20,6 +20,7 @@ /*