Skip to content

Commit

Permalink
Merge branch 'hoxfix/#204-bug-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
violet-mj committed Aug 25, 2024
2 parents ab2e341 + 8564739 commit 1559688
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
21 changes: 16 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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'

Expand All @@ -73,4 +84,4 @@ dependencies {
tasks.named('test') {
jvmArgs = ["-Dspring.profiles.active=test"]
useJUnitPlatform()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
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
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)
Expand All @@ -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;
}
}
1 change: 1 addition & 0 deletions src/main/resources/templates/preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/*<![CDATA[*/
window.addEventListener('load', function() {
const baseUrl = /*[[${apiUrl}]]*/ '';
const sharedUrl = /*[[${sharedUrl}]]*/ '';
const url = `${baseUrl}/url/${sharedUrl}`;
// fetch를 사용하여 GET 요청 보내기
fetch(url)
Expand Down

0 comments on commit 1559688

Please sign in to comment.