Skip to content

Commit

Permalink
Merge pull request #39 from Na-o-man/fix/#38/fix-photoList-response
Browse files Browse the repository at this point in the history
[FIX] 사진 조회 API 반환값 수정
  • Loading branch information
bflykky authored Aug 1, 2024
2 parents 63a47eb + 7553a85 commit 12a9ced
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,27 @@ public PhotoResponse.PagedPhotoInfo toPhotoListInfo(Page<Photo> 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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 12a9ced

Please sign in to comment.