From 3ea37014d90760fb3502d6ba11238c243f31090b Mon Sep 17 00:00:00 2001 From: Donghoon Jeong <112836685+jjeongdong@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:44:57 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix=20:=20=EC=82=AC=EC=A7=84=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20=EB=B0=98=ED=99=98=EA=B0=92=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/photo/converter/PhotoConverter.java | 16 ++++++++++++---- .../naoman/domain/photo/dto/PhotoResponse.java | 6 +++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/umc/naoman/domain/photo/converter/PhotoConverter.java b/src/main/java/com/umc/naoman/domain/photo/converter/PhotoConverter.java index 3a22467..3605d86 100644 --- a/src/main/java/com/umc/naoman/domain/photo/converter/PhotoConverter.java +++ b/src/main/java/com/umc/naoman/domain/photo/converter/PhotoConverter.java @@ -57,17 +57,25 @@ public PhotoResponse.PagedPhotoInfo toPhotoListInfo(Page photoList) { } public PhotoResponse.PhotoInfo toPhotoInfo(Photo photo) { + String rawUrl = photo.getUrl(); + return PhotoResponse.PhotoInfo.builder() - .photoUrl(photo.getUrl()) - .photoName(photo.getName()) - .resizedPhotoName(convertExtension(photo.getName())) + .rawPhotoUrl(rawUrl) + .w200PhotoUrl(createResizedPhotoUrl(rawUrl, "w200")) + .w400PhotoUrl(createResizedPhotoUrl(rawUrl, "w400")) .createdAt(photo.getCreatedAt()) .build(); } - // HEIC에서 JPG로 확장자를 변환하는 메서드 + // Helper method to create resized photo URL + private String createResizedPhotoUrl(String photoUrl, String size) { + return convertExtension(photoUrl.replace("/raw/", "/" + size + "/")); + } + + // HEIC to JPG conversion method private String convertExtension(String photoUrl) { return photoUrl.replace(".HEIC", ".jpg"); } + } diff --git a/src/main/java/com/umc/naoman/domain/photo/dto/PhotoResponse.java b/src/main/java/com/umc/naoman/domain/photo/dto/PhotoResponse.java index 9d6de77..2eaf9ac 100644 --- a/src/main/java/com/umc/naoman/domain/photo/dto/PhotoResponse.java +++ b/src/main/java/com/umc/naoman/domain/photo/dto/PhotoResponse.java @@ -54,9 +54,9 @@ public static class PagedPhotoInfo { @AllArgsConstructor @NoArgsConstructor public static class PhotoInfo { - private String photoUrl; - private String photoName; - private String resizedPhotoName; + private String rawPhotoUrl; + private String w200PhotoUrl; + private String w400PhotoUrl; private LocalDateTime createdAt; } } From 7553a852fd26cca3a60772612af4e77281a8bbf1 Mon Sep 17 00:00:00 2001 From: Donghoon Jeong <112836685+jjeongdong@users.noreply.github.com> Date: Thu, 1 Aug 2024 10:42:39 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refact=20:=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/photo/converter/PhotoConverter.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/umc/naoman/domain/photo/converter/PhotoConverter.java b/src/main/java/com/umc/naoman/domain/photo/converter/PhotoConverter.java index 3605d86..bb5ee47 100644 --- a/src/main/java/com/umc/naoman/domain/photo/converter/PhotoConverter.java +++ b/src/main/java/com/umc/naoman/domain/photo/converter/PhotoConverter.java @@ -67,15 +67,19 @@ public PhotoResponse.PhotoInfo toPhotoInfo(Photo photo) { .build(); } - // Helper method to create resized photo URL private String createResizedPhotoUrl(String photoUrl, String size) { - return convertExtension(photoUrl.replace("/raw/", "/" + size + "/")); + String resizedUrl = getResizedUrl(photoUrl, size); + return convertExtension(resizedUrl); } - // HEIC to JPG conversion method + // 리사이즈된 사진의 URL로 변환하는 메서드 + private String getResizedUrl(String photoUrl, String size) { + return photoUrl.replace("/raw/", "/" + size + "/"); + } + + // 확장자 변환 메서드 private String convertExtension(String photoUrl) { return photoUrl.replace(".HEIC", ".jpg"); } - }