Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public record CommentResponse(
Long commentId,
String content,
AuthorDto author,
Long imageId,
Long voteImageId,
LocalDateTime createdAt
) implements CursorDto {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PostImageResponse> 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<PostImageResponse> createPostImageResponse(Long userId, Long postId, Post post) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public ResponseEntity<PostResponse> 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)
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ public record PostResponse(
String description,
List<PostImageResponse> images,
String shareUrl,
boolean isAuthor,
LocalDateTime createdAt
) {
public static PostResponse of(Post post, User user, List<PostImageResponse> images) {
public static PostResponse of(Post post, User user, List<PostImageResponse> images, boolean isAuthor) {
return new PostResponse(
post.getId(),
AuthorDto.of(user),
post.getDescription(),
images,
post.getShareUrl(),
isAuthor,
post.getCreatedAt()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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("κ²Œμ‹œκΈ€ μž‘μ„±μž μ—¬λΆ€")
)
));
}
Expand Down