diff --git a/src/docs/asciidoc/posts.adoc b/src/docs/asciidoc/posts.adoc index 55a433b8..6206b90b 100644 --- a/src/docs/asciidoc/posts.adoc +++ b/src/docs/asciidoc/posts.adoc @@ -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` 내가 작성한 게시글 조회 diff --git a/src/main/java/com/swyp8team2/common/presentation/HttpLoggingFilter.java b/src/main/java/com/swyp8team2/common/presentation/HttpLoggingFilter.java index 8d235e3a..1794ab22 100644 --- a/src/main/java/com/swyp8team2/common/presentation/HttpLoggingFilter.java +++ b/src/main/java/com/swyp8team2/common/presentation/HttpLoggingFilter.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.Objects; import java.util.UUID; +import java.util.stream.Stream; @Slf4j @Component @@ -79,15 +80,16 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse private String getHeaders(HttpServletRequest request) { StringBuilder sb = new StringBuilder("{\n"); - List loggingHeaders = List.of( - HttpHeaders.USER_AGENT, - HttpHeaders.AUTHORIZATION, - HttpHeaders.COOKIE, - HttpHeaders.CONTENT_TYPE, - HttpHeaders.HOST, - HttpHeaders.REFERER, - HttpHeaders.ORIGIN - ); + List 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 headerArray = request.getHeaderNames(); while (headerArray.hasMoreElements()) { String headerName = headerArray.nextElement(); diff --git a/src/main/java/com/swyp8team2/post/application/PostService.java b/src/main/java/com/swyp8team2/post/application/PostService.java index 1eb11b6f..ae02e2e9 100644 --- a/src/main/java/com/swyp8team2/post/application/PostService.java +++ b/src/main/java/com/swyp8team2/post/application/PostService.java @@ -120,7 +120,7 @@ public List 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(); } diff --git a/src/main/java/com/swyp8team2/post/presentation/dto/PostImageVoteStatusResponse.java b/src/main/java/com/swyp8team2/post/presentation/dto/PostImageVoteStatusResponse.java index 652f0899..56c0f57f 100644 --- a/src/main/java/com/swyp8team2/post/presentation/dto/PostImageVoteStatusResponse.java +++ b/src/main/java/com/swyp8team2/post/presentation/dto/PostImageVoteStatusResponse.java @@ -1,6 +1,7 @@ package com.swyp8team2.post.presentation.dto; public record PostImageVoteStatusResponse( + Long id, String imageName, int voteCount, String voteRatio diff --git a/src/test/java/com/swyp8team2/post/application/PostServiceTest.java b/src/test/java/com/swyp8team2/post/application/PostServiceTest.java index 6921d19a..b86dd717 100644 --- a/src/test/java/com/swyp8team2/post/application/PostServiceTest.java +++ b/src/test/java/com/swyp8team2/post/application/PostServiceTest.java @@ -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") diff --git a/src/test/java/com/swyp8team2/post/presentation/PostControllerTest.java b/src/test/java/com/swyp8team2/post/presentation/PostControllerTest.java index 809dc400..11c0659c 100644 --- a/src/test/java/com/swyp8team2/post/presentation/PostControllerTest.java +++ b/src/test/java/com/swyp8team2/post/presentation/PostControllerTest.java @@ -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); @@ -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("투표 비율")