diff --git a/src/main/java/com/spaceclub/board/controller/dto/CommentResponse.java b/src/main/java/com/spaceclub/board/controller/dto/CommentResponse.java index 080371b7..6ef891d0 100644 --- a/src/main/java/com/spaceclub/board/controller/dto/CommentResponse.java +++ b/src/main/java/com/spaceclub/board/controller/dto/CommentResponse.java @@ -21,7 +21,7 @@ public static CommentResponse of(CommentInfo commentInfo, String bucketUrl) { commentInfo.content(), commentInfo.authorId(), commentInfo.author(), - commentInfo.authorImageUrl() == null ? null : bucketUrl + commentInfo.authorImageUrl(), + commentInfo.authorImageUrl(), commentInfo.createdDate(), commentInfo.lastModifiedDate(), commentInfo.isPrivate() diff --git a/src/main/java/com/spaceclub/board/controller/dto/PostResponse.java b/src/main/java/com/spaceclub/board/controller/dto/PostResponse.java index a5e8b473..b9869854 100644 --- a/src/main/java/com/spaceclub/board/controller/dto/PostResponse.java +++ b/src/main/java/com/spaceclub/board/controller/dto/PostResponse.java @@ -23,8 +23,8 @@ public static PostResponse from(PostInfo postInfo, String bucketUrl) { postInfo.content(), postInfo.authorId(), postInfo.author(), - postInfo.authorImageUrl() == null ? null : bucketUrl + postInfo.authorImageUrl(), - postInfo.postImageUrl() == null ? null : bucketUrl + postInfo.postImageUrl(), + postInfo.authorImageUrl(), + postInfo.postImageUrl(bucketUrl), postInfo.createdDate(), postInfo.lastModifiedDate() ); diff --git a/src/main/java/com/spaceclub/board/service/vo/PostInfo.java b/src/main/java/com/spaceclub/board/service/vo/PostInfo.java index b7a20230..3bf5d224 100644 --- a/src/main/java/com/spaceclub/board/service/vo/PostInfo.java +++ b/src/main/java/com/spaceclub/board/service/vo/PostInfo.java @@ -31,4 +31,12 @@ public static PostInfo of(Post post, UserProfile userProfile) { post.getLastModifiedAt() ); } + + public String postImageUrl(String bucketUrl) { + if (postImageUrl == null) { + return null; + } + return bucketUrl + postImageUrl; + } + } diff --git a/src/test/java/com/spaceclub/board/controller/CommentControllerTest.java b/src/test/java/com/spaceclub/board/controller/CommentControllerTest.java index 0fdb93bd..78aab7cc 100644 --- a/src/test/java/com/spaceclub/board/controller/CommentControllerTest.java +++ b/src/test/java/com/spaceclub/board/controller/CommentControllerTest.java @@ -204,7 +204,7 @@ class CommentControllerTest { .andExpect(jsonPath("$.content").value(comment.getContent())) .andExpect(jsonPath("$.authorId").value(comment.getAuthorId())) .andExpect(jsonPath("$.author").value(userProfile.username())) - .andExpect(jsonPath("$.authorImageUrl").value(bucketUrl + userProfile.profileImageUrl())) + .andExpect(jsonPath("$.authorImageUrl").value(userProfile.profileImageUrl())) .andExpect(jsonPath("$.createdDate").value("2024-01-01T00:00:00")) .andExpect(jsonPath("$.lastModifiedDate").value("2024-01-01T00:00:00")) .andExpect(jsonPath("$.isPrivate").value(comment.isPrivate())) diff --git a/src/test/java/com/spaceclub/board/controller/PostControllerTest.java b/src/test/java/com/spaceclub/board/controller/PostControllerTest.java index 2846e4df..02faddbb 100644 --- a/src/test/java/com/spaceclub/board/controller/PostControllerTest.java +++ b/src/test/java/com/spaceclub/board/controller/PostControllerTest.java @@ -216,7 +216,7 @@ class PostControllerTest { .andExpect(jsonPath("$.content").value(post.getContent())) .andExpect(jsonPath("$.authorId").value(post.getAuthorId())) .andExpect(jsonPath("$.author").value(userProfile.username())) - .andExpect(jsonPath("$.authorImageUrl").value(bucketUrl + userProfile.profileImageUrl())) + .andExpect(jsonPath("$.authorImageUrl").value(userProfile.profileImageUrl())) .andExpect(jsonPath("$.postImageUrl").value(bucketUrl + post.getPostImageUrl())) .andExpect(jsonPath("$.createdDate").value("2024-01-01T00:00:00")) .andExpect(jsonPath("$.lastModifiedDate").value("2024-01-01T00:00:00"))