From 31232dfcac20547515b024cb29443d83d317af3a Mon Sep 17 00:00:00 2001 From: juno-junho Date: Sat, 27 Jan 2024 21:06:39 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20user=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20url?= =?UTF-8?q?=EC=95=9E=EC=97=90=20bucket=20url=20prefix=EA=B0=80=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=EC=9C=BC=EB=A1=9C=20=EB=B6=99=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spaceclub/board/controller/dto/CommentResponse.java | 2 +- .../com/spaceclub/board/controller/dto/PostResponse.java | 4 ++-- .../java/com/spaceclub/board/service/vo/PostInfo.java | 8 ++++++++ .../spaceclub/board/controller/CommentControllerTest.java | 2 +- .../spaceclub/board/controller/PostControllerTest.java | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) 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"))