Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : 단축 URL공유 텍스트 수정, 이미지를 환경변수로 관리 (CC-179) #48

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

Expand All @@ -24,6 +25,9 @@ public class ShortUrlService {

private final int SHORT_URL_LENGTH = 7;

@Value("${images.preview}")
private String previewImageUrl;

/**
* 레이싱게임 순위 단축 URL로 공유하기 기능
*
Expand Down Expand Up @@ -95,19 +99,22 @@ public ResponseEntity<?> shortUrlToLongUrl(String shortUrl) {
* @return
*/
public ResponseEntity<?> previewUrl(ShareUrlRequestDto req) {
String distance = String.format("%.3f", req.distance());
String percentage = String.format("%.1f", req.percentage());

return ResponseEntity.status(200)
.header("Content-Type", "text/html; charset=utf-8")
.body(
"<html>" +
"<head>" +
"<head>" +
"<meta charset=\"utf-8\">" +
"<meta property=\"og:type\" content=\"website\" />" +
"<meta property=\"og:title\" content=\"레이싱 게임\">" +
"<meta property=\"og:image\" content=\"https://contents-cdn.viewus.co.kr/image/2024/07/CP-2023-0096/image-b868c07a-8a04-44cc-9f07-a591905a3680.jpeg\">" +
"<meta property=\"og:description\" content=\"이동 거리 " + req.distance() + "KM / 상위 " + req.percentage() + "%\">" +
"</head>" +
"<body><script>location.href=\"http://www.caecae.kro.kr/racecasper\";</script></body>" +
"</html>"
"<meta property=\"og:title\" content=\"친구의 기록에 도전하세요!\">" +
"<meta property=\"og:image\" content=\"" + previewImageUrl + "\">" +
"<meta property=\"og:description\" content=\"상위 " + percentage + "% (거리 : " + distance + "km)\">" +
"</head>" +
"<body><script>location.href=\"http://www.caecae.kro.kr/racecasper\";</script></body>" +
"</html>"
);
}
}
5 changes: 4 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ spring:
database-platform: org.hibernate.dialect.MySQLDialect
open-in-view: false


s3:
bucket: ${S3_BUCKET}
region:
Expand All @@ -40,3 +39,7 @@ management:
web:
exposure:
include: "prometheus"

images:
preview: ${PREVIEW_IMAGE}

Loading