From c554bad1beeed65b5a638fec0671061eaf0daec1 Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 16:09:32 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=EB=8C=93=EA=B8=80=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=EC=9E=90=20=ED=88=AC=ED=91=9C=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20id=20=ED=95=84=EB=93=9C=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../swyp8team2/comment/presentation/dto/CommentResponse.java | 2 +- .../swyp8team2/comment/presentation/CommentControllerTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java b/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java index 30af16ab..ea3c6f67 100644 --- a/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java +++ b/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java @@ -11,7 +11,7 @@ public record CommentResponse( Long commentId, String content, AuthorDto author, - Long imageId, + Long voteImageId, LocalDateTime createdAt ) implements CursorDto { diff --git a/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java b/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java index 46dfbf8b..ab316900 100644 --- a/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java +++ b/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java @@ -119,7 +119,7 @@ void findComments() throws Exception { fieldWithPath("data[].author.profileUrl") .type(JsonFieldType.STRING) .description("작성자 프로필 이미지 url"), - fieldWithPath("data[].imageId") + fieldWithPath("data[].voteImageId") .type(JsonFieldType.NUMBER) .optional() .description("작성자가 투표한 이미지 Id (투표 없을 시 null)"), From abf1c3e6f010f31f835a6a822eaece2c46d90ca7 Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 16:09:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=ED=88=AC=ED=91=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=EC=9E=90=20=EB=B3=B8=EC=9D=B8=20=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/swyp8team2/post/application/PostService.java | 3 ++- .../java/com/swyp8team2/post/presentation/PostController.java | 1 + .../com/swyp8team2/post/presentation/dto/PostResponse.java | 4 +++- .../com/swyp8team2/post/presentation/PostControllerTest.java | 4 +++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/swyp8team2/post/application/PostService.java b/src/main/java/com/swyp8team2/post/application/PostService.java index f39e5c1e..b9279815 100644 --- a/src/main/java/com/swyp8team2/post/application/PostService.java +++ b/src/main/java/com/swyp8team2/post/application/PostService.java @@ -61,7 +61,8 @@ public PostResponse findById(Long userId, Long postId) { User author = userRepository.findById(post.getUserId()) .orElseThrow(() -> new BadRequestException(ErrorCode.USER_NOT_FOUND)); List votes = createPostImageResponse(userId, postId, post); - return PostResponse.of(post, author, votes); + boolean isAuthor = post.getUserId().equals(userId); + return PostResponse.of(post, author, votes, isAuthor); } private List createPostImageResponse(Long userId, Long postId, Post post) { diff --git a/src/main/java/com/swyp8team2/post/presentation/PostController.java b/src/main/java/com/swyp8team2/post/presentation/PostController.java index ca181605..ac5e33d9 100644 --- a/src/main/java/com/swyp8team2/post/presentation/PostController.java +++ b/src/main/java/com/swyp8team2/post/presentation/PostController.java @@ -77,6 +77,7 @@ public ResponseEntity findPost(@PathVariable("shareUrl") String sh new PostImageResponse(2L, "뽀또B", "https://image.photopic.site/image/2", "https://image.photopic.site/image/resize/1", false) ), "https://photopic.site/shareurl", + true, LocalDateTime.of(2025, 2, 13, 12, 0) )); } diff --git a/src/main/java/com/swyp8team2/post/presentation/dto/PostResponse.java b/src/main/java/com/swyp8team2/post/presentation/dto/PostResponse.java index cb32afc3..6f082117 100644 --- a/src/main/java/com/swyp8team2/post/presentation/dto/PostResponse.java +++ b/src/main/java/com/swyp8team2/post/presentation/dto/PostResponse.java @@ -12,15 +12,17 @@ public record PostResponse( String description, List images, String shareUrl, + boolean isAuthor, LocalDateTime createdAt ) { - public static PostResponse of(Post post, User user, List images) { + public static PostResponse of(Post post, User user, List images, boolean isAuthor) { return new PostResponse( post.getId(), AuthorDto.of(user), post.getDescription(), images, post.getShareUrl(), + isAuthor, post.getCreatedAt() ); } diff --git a/src/test/java/com/swyp8team2/post/presentation/PostControllerTest.java b/src/test/java/com/swyp8team2/post/presentation/PostControllerTest.java index 6af99fb9..1ca9d1cc 100644 --- a/src/test/java/com/swyp8team2/post/presentation/PostControllerTest.java +++ b/src/test/java/com/swyp8team2/post/presentation/PostControllerTest.java @@ -90,6 +90,7 @@ void findPost() throws Exception { new PostImageResponse(2L, "뽀또B", "https://image.photopic.site/image/2", "https://image.photopic.site/image/resize/2", false) ), "https://photopic.site/shareurl", + true, LocalDateTime.of(2025, 2, 13, 12, 0) ); given(postService.findById(any(), any())) @@ -117,7 +118,8 @@ void findPost() throws Exception { fieldWithPath("images[].thumbnailUrl").type(JsonFieldType.STRING).description("확대 사진 이미지"), fieldWithPath("images[].voted").type(JsonFieldType.BOOLEAN).description("투표 여부"), fieldWithPath("shareUrl").type(JsonFieldType.STRING).description("게시글 공유 URL"), - fieldWithPath("createdAt").type(JsonFieldType.STRING).description("게시글 생성 시간") + fieldWithPath("createdAt").type(JsonFieldType.STRING).description("게시글 생성 시간"), + fieldWithPath("isAuthor").type(JsonFieldType.BOOLEAN).description("게시글 작성자 여부") ) )); }