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..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 @@ -57,15 +57,27 @@ 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로 확장자를 변환하는 메서드 + private String createResizedPhotoUrl(String photoUrl, String size) { + String resizedUrl = getResizedUrl(photoUrl, size); + return convertExtension(resizedUrl); + } + + // 리사이즈된 사진의 URL로 변환하는 메서드 + private String getResizedUrl(String photoUrl, String size) { + return photoUrl.replace("/raw/", "/" + size + "/"); + } + + // 확장자 변환 메서드 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; } }