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
1 change: 0 additions & 1 deletion src/docs/asciidoc/posts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ operation::post-controller-test/find-post[snippets='http-request,curl-request,pa

operation::post-controller-test/find-vote-status[snippets='http-request,curl-request,request-headers,path-parameters,http-response,response-fields']

[[게시글-목록-조회]]

[[내가-작성한-게시글-조회]]
=== `GET` 내가 작성한 게시글 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Stream;

@Slf4j
@Component
Expand Down Expand Up @@ -79,15 +80,16 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
private String getHeaders(HttpServletRequest request) {
StringBuilder sb = new StringBuilder("{\n");

List<String> loggingHeaders = List.of(
HttpHeaders.USER_AGENT,
HttpHeaders.AUTHORIZATION,
HttpHeaders.COOKIE,
HttpHeaders.CONTENT_TYPE,
HttpHeaders.HOST,
HttpHeaders.REFERER,
HttpHeaders.ORIGIN
);
List<String> loggingHeaders = Stream.of(
HttpHeaders.USER_AGENT.toLowerCase(),
HttpHeaders.AUTHORIZATION.toLowerCase(),
HttpHeaders.COOKIE.toLowerCase(),
HttpHeaders.CONTENT_TYPE.toLowerCase(),
HttpHeaders.HOST.toLowerCase(),
HttpHeaders.REFERER.toLowerCase(),
HttpHeaders.ORIGIN.toLowerCase()
).map(String::toLowerCase)
.toList();
Enumeration<String> headerArray = request.getHeaderNames();
while (headerArray.hasMoreElements()) {
String headerName = headerArray.nextElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public List<PostImageVoteStatusResponse> findPostStatus(Long postId) {
return post.getImages().stream()
.map(image -> {
String ratio = ratioCalculator.calculate(image.getVoteCount(), totalVoteCount);
return new PostImageVoteStatusResponse(image.getName(), image.getVoteCount(), ratio);
return new PostImageVoteStatusResponse(image.getId(), image.getName(), image.getVoteCount(), ratio);
}).toList();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.swyp8team2.post.presentation.dto;

public record PostImageVoteStatusResponse(
Long id,
String imageName,
int voteCount,
String voteRatio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@ void findPostStatus() throws Exception {
//then
assertAll(
() -> assertThat(response).hasSize(2),
() -> assertThat(response.get(0).id()).isEqualTo(post.getImages().get(0).getId()),
() -> assertThat(response.get(0).imageName()).isEqualTo(post.getImages().get(0).getName()),
() -> assertThat(response.get(0).voteCount()).isEqualTo(1),
() -> assertThat(response.get(0).voteRatio()).isEqualTo("100.0"),
() -> assertThat(response.get(1).id()).isEqualTo(post.getImages().get(1).getId()),
() -> assertThat(response.get(1).imageName()).isEqualTo(post.getImages().get(1).getName()),
() -> assertThat(response.get(1).voteCount()).isEqualTo(0),
() -> assertThat(response.get(1).voteRatio()).isEqualTo("0.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ void findPost() throws Exception {
void findVoteStatus() throws Exception {
//given
var response = List.of(
new PostImageVoteStatusResponse("뽀또A", 2, "66.7"),
new PostImageVoteStatusResponse("뽀또B", 1, "33.3")
new PostImageVoteStatusResponse(1L, "뽀또A", 2, "66.7"),
new PostImageVoteStatusResponse(2L, "뽀또B", 1, "33.3")
);
given(postService.findPostStatus(1L))
.willReturn(response);
Expand All @@ -143,6 +143,7 @@ void findVoteStatus() throws Exception {
),
responseFields(
fieldWithPath("[]").type(JsonFieldType.ARRAY).description("투표 선택지 목록"),
fieldWithPath("[].id").type(JsonFieldType.NUMBER).description("이미지 Id"),
fieldWithPath("[].imageName").type(JsonFieldType.STRING).description("사진 이름"),
fieldWithPath("[].voteCount").type(JsonFieldType.NUMBER).description("투표 수"),
fieldWithPath("[].voteRatio").type(JsonFieldType.STRING).description("투표 비율")
Expand Down