From aa24789357a80910abc5dcb228ccdba9dbef33d6 Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Tue, 25 Feb 2025 15:13:53 +0900 Subject: [PATCH 1/5] =?UTF-8?q?refactor:=20=ED=88=AC=ED=91=9C=20=ED=98=84?= =?UTF-8?q?=ED=99=A9=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20id=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/swyp8team2/post/application/PostService.java | 2 +- .../post/presentation/dto/PostImageVoteStatusResponse.java | 1 + .../java/com/swyp8team2/post/application/PostServiceTest.java | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) 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") From 08fbd84d746ca2c230ef7f8c17c03f8c028c69ff Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Tue, 25 Feb 2025 15:14:17 +0900 Subject: [PATCH 2/5] =?UTF-8?q?docs:=20=ED=95=84=EC=9A=94=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EB=B6=80=EB=B6=84=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/posts.adoc | 1 - 1 file changed, 1 deletion(-) 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` 내가 작성한 게시글 조회 From b4bb9fa9c376bac9a992ab255b0eaae0cf877049 Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Tue, 25 Feb 2025 15:14:17 +0900 Subject: [PATCH 3/5] =?UTF-8?q?docs:=20=ED=95=84=EC=9A=94=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EB=B6=80=EB=B6=84=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/posts.adoc | 1 - 1 file changed, 1 deletion(-) 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` 내가 작성한 게시글 조회 From 3427dff36efcf21f24affed0307080b1edd06aad Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Tue, 25 Feb 2025 15:13:53 +0900 Subject: [PATCH 4/5] =?UTF-8?q?refactor:=20=ED=88=AC=ED=91=9C=20=ED=98=84?= =?UTF-8?q?=ED=99=A9=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20id=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=BC=20=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 | 2 +- .../post/presentation/dto/PostImageVoteStatusResponse.java | 1 + .../com/swyp8team2/post/application/PostServiceTest.java | 2 ++ .../com/swyp8team2/post/presentation/PostControllerTest.java | 5 +++-- 4 files changed, 7 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 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("투표 비율") From b588ad11516f5c525769a2d0a4583f1ba6458a35 Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Tue, 25 Feb 2025 15:39:15 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20http=20=EB=A1=9C=EA=B9=85=20?= =?UTF-8?q?=ED=97=A4=EB=8D=94=20=ED=91=9C=EC=8B=9C=20=EC=95=88=20=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/HttpLoggingFilter.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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();