From bb916c9fb9b3d0466ac38729347b106b69f4ea42 Mon Sep 17 00:00:00 2001 From: ayoung-dev Date: Tue, 3 Dec 2024 21:47:09 +0900 Subject: [PATCH 1/8] =?UTF-8?q?test(community):=20community=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=EA=B8=80,=20=EB=8C=93=EA=B8=80=20controller=20test=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 --- ...ommunityBoardCommandApiControllerTest.java | 171 ++++++++++++++++++ .../CommunityBoardQueryApiControllerTest.java | 104 +++++++++++ ...munityCommentCommandApiControllerTest.java | 146 +++++++++++++++ ...ommunityCommentQueryApiControllerTest.java | 57 ++++++ 4 files changed, 478 insertions(+) create mode 100644 src/test/java/com/somemore/community/controller/CommunityBoardCommandApiControllerTest.java create mode 100644 src/test/java/com/somemore/community/controller/CommunityBoardQueryApiControllerTest.java create mode 100644 src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java create mode 100644 src/test/java/com/somemore/community/controller/CommunityCommentQueryApiControllerTest.java diff --git a/src/test/java/com/somemore/community/controller/CommunityBoardCommandApiControllerTest.java b/src/test/java/com/somemore/community/controller/CommunityBoardCommandApiControllerTest.java new file mode 100644 index 000000000..75c02276f --- /dev/null +++ b/src/test/java/com/somemore/community/controller/CommunityBoardCommandApiControllerTest.java @@ -0,0 +1,171 @@ +package com.somemore.community.controller; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willDoNothing; +import static org.springframework.http.MediaType.MULTIPART_FORM_DATA; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.somemore.ControllerTestSupport; +import com.somemore.WithMockCustomUser; +import com.somemore.community.dto.request.CommunityBoardCreateRequestDto; +import com.somemore.community.dto.request.CommunityBoardUpdateRequestDto; +import com.somemore.community.usecase.board.CreateCommunityBoardUseCase; +import com.somemore.community.usecase.board.DeleteCommunityBoardUseCase; +import com.somemore.community.usecase.board.UpdateCommunityBoardUseCase; +import com.somemore.imageupload.usecase.ImageUploadUseCase; +import java.util.UUID; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder; +import org.springframework.test.web.servlet.request.RequestPostProcessor; + +public class CommunityBoardCommandApiControllerTest extends ControllerTestSupport { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private ObjectMapper objectMapper; + + @MockBean + private CreateCommunityBoardUseCase createCommunityBoardUseCase; + + @MockBean + private UpdateCommunityBoardUseCase updateCommunityBoardUseCase; + + @MockBean + private DeleteCommunityBoardUseCase deleteCommunityBoardUseCase; + + @MockBean + private ImageUploadUseCase imageUploadUseCase; + + @Test + @DisplayName("커뮤니티 게시글 등록 성공 테스트") + @WithMockCustomUser + void createCommunityBoard_success() throws Exception { + //given + CommunityBoardCreateRequestDto dto = CommunityBoardCreateRequestDto.builder() + .title("11/29 OO도서관 봉사 같이 갈 사람 모집합니다.") + .content("저 포함 5명이 같이 가면 좋을 거 같아요.") + .build(); + + MockMultipartFile imageFile = new MockMultipartFile( + "img_file", + "test-image.jpg", + MediaType.IMAGE_JPEG_VALUE, + "test image content".getBytes() + ); + + MockMultipartFile requestData = new MockMultipartFile( + "data", + "", + MediaType.APPLICATION_JSON_VALUE, + objectMapper.writeValueAsBytes(dto) + ); + + String mockImageUrl = "http://example.com/image/test-image.jpg"; + long communityBoardId = 1L; + + given(imageUploadUseCase.uploadImage(any())).willReturn(mockImageUrl); + given(createCommunityBoardUseCase.createCommunityBoard(any(), any(UUID.class), + anyString())).willReturn(communityBoardId); + + //when + mockMvc.perform(multipart("/api/community-board") + .file(requestData) + .file(imageFile) + .contentType(MULTIPART_FORM_DATA) + .header("Authorization", "Bearer access-token")) + //then + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(201)) + .andExpect(jsonPath("$.data").value(communityBoardId)) + .andExpect(jsonPath("$.message").value("커뮤니티 게시글 등록 성공")); + } + + @Test + @DisplayName("커뮤니티 게시글 수정 성공 테스트") + @WithMockCustomUser + void updateCommunityBoard_success() throws Exception { + //given + CommunityBoardUpdateRequestDto requestDto = CommunityBoardUpdateRequestDto.builder() + .title("XX아동센터 추천합니다.") + .content("지난 주 토요일에 방문했는데 강추드려요.") + .build(); + + MockMultipartFile imageFile = new MockMultipartFile( + "img_file", + "test-image.jpg", + MediaType.IMAGE_JPEG_VALUE, + "test image content".getBytes() + ); + + MockMultipartFile requestData = new MockMultipartFile( + "data", + "", + MediaType.APPLICATION_JSON_VALUE, + objectMapper.writeValueAsBytes(requestDto) + ); + + String imageUrl = "http://example.com/image/test-image.jpg"; + + given(imageUploadUseCase.uploadImage(any())).willReturn(imageUrl); + willDoNothing().given(updateCommunityBoardUseCase) + .updateCommunityBoard(any(), any(), any(UUID.class), anyString()); + + MockMultipartHttpServletRequestBuilder builder = multipart("/api/community-board/{id}", 1); + builder.with(new RequestPostProcessor() { + @Override + public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { + request.setMethod("PUT"); + return request; + } + }); + + //when + mockMvc.perform(builder + .file(requestData) + .file(imageFile) + .contentType(MULTIPART_FORM_DATA) + .header("Authorization", "Bearer access-token")) + + //then + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andExpect(jsonPath("$.data").isEmpty()) + .andExpect(jsonPath("$.message").value("커뮤니티 게시글 수정 성공")); + } + + @Test + @DisplayName("커뮤니티 게시글 삭제 성공 테스트") + @WithMockCustomUser + void deleteCommunityBoard_success() throws Exception { + //given + Long communityBoardId = 1L; + willDoNothing().given(deleteCommunityBoardUseCase).deleteCommunityBoard(any(UUID.class), any()); + + //when + mockMvc.perform(delete("/api/community-board/{id}", communityBoardId) + .header("Authorization", "Bearer access-token")) + //then + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andExpect(jsonPath("$.message").value("커뮤니티 게시글 삭제 성공")) + .andExpect(jsonPath("$.data").isEmpty()); + } +} diff --git a/src/test/java/com/somemore/community/controller/CommunityBoardQueryApiControllerTest.java b/src/test/java/com/somemore/community/controller/CommunityBoardQueryApiControllerTest.java new file mode 100644 index 000000000..3d2fb8eb6 --- /dev/null +++ b/src/test/java/com/somemore/community/controller/CommunityBoardQueryApiControllerTest.java @@ -0,0 +1,104 @@ +package com.somemore.community.controller; + +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.somemore.ControllerTestSupport; +import com.somemore.community.dto.response.CommunityBoardDetailResponseDto; +import com.somemore.community.dto.response.CommunityBoardResponseDto; +import com.somemore.community.usecase.board.CommunityBoardQueryUseCase; +import java.util.Collections; +import java.util.UUID; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; + +public class CommunityBoardQueryApiControllerTest extends ControllerTestSupport { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private CommunityBoardQueryUseCase communityBoardQueryUseCase; + + @Test + @DisplayName("커뮤니티 게시글 전체 조회 성공") + void getAll() throws Exception { + //given + Page page = new PageImpl<>(Collections.emptyList()); + + given(communityBoardQueryUseCase.getCommunityBoards(anyInt())) + .willReturn(page); + + //when + //then + mockMvc.perform(get("/api/community-boards") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andExpect(jsonPath("$.data").exists()) + .andExpect(jsonPath("$.message") + .value("전체 커뮤니티 게시글 리스트 조회 성공")); + + verify(communityBoardQueryUseCase, times(1)) + .getCommunityBoards(anyInt()); + } + + @Test + @DisplayName("작성자별 커뮤니티 게시글 조회 성공") + void getByWriterId() throws Exception { + //given + UUID writerId = UUID.randomUUID(); + Page page = new PageImpl<>(Collections.emptyList()); + + given(communityBoardQueryUseCase.getCommunityBoardsByWriterId(any(), anyInt())) + .willReturn(page); + + //when + //then + mockMvc.perform(get("/api/community-boards/{writer_id}", writerId) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andExpect(jsonPath("$.data").exists()) + .andExpect(jsonPath("$.message") + .value("작성자별 커뮤니티 게시글 리스트 조회 성공")); + + verify(communityBoardQueryUseCase, times(1)) + .getCommunityBoardsByWriterId(any(), anyInt()); + } + + @Test + @DisplayName("커뮤니티 게시글 상세 조회 성공") + void getById() throws Exception { + //given + Long communityBoardId = 1L; + CommunityBoardDetailResponseDto responseDto = CommunityBoardDetailResponseDto.builder().build(); + given(communityBoardQueryUseCase.getCommunityBoardDetail(any())) + .willReturn(responseDto); + + //when + //then + mockMvc.perform(get("/api/community-board/{id}", communityBoardId) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andExpect(jsonPath("$.data").exists()) + .andExpect(jsonPath("$.message") + .value("커뮤니티 게시글 상세 조회 성공")); + + verify(communityBoardQueryUseCase, times(1)) + .getCommunityBoardDetail(any()); + } +} diff --git a/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java b/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java new file mode 100644 index 000000000..e4b7ebd94 --- /dev/null +++ b/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java @@ -0,0 +1,146 @@ +package com.somemore.community.controller; + +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willDoNothing; +import static org.springframework.http.MediaType.MULTIPART_FORM_DATA; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.somemore.ControllerTestSupport; +import com.somemore.WithMockCustomUser; +import com.somemore.community.dto.request.CommunityCommentCreateRequestDto; +import com.somemore.community.dto.request.CommunityCommentUpdateRequestDto; +import com.somemore.community.usecase.comment.CreateCommunityCommentUseCase; +import com.somemore.community.usecase.comment.DeleteCommunityCommentUseCase; +import com.somemore.community.usecase.comment.UpdateCommunityCommentUseCase; +import java.util.UUID; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder; +import org.springframework.test.web.servlet.request.RequestPostProcessor; + +public class CommunityCommentCommandApiControllerTest extends ControllerTestSupport { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private ObjectMapper objectMapper; + + @MockBean + private CreateCommunityCommentUseCase createCommunityCommentUseCase; + + @MockBean + private UpdateCommunityCommentUseCase updateCommunityCommentUseCase; + + @MockBean + private DeleteCommunityCommentUseCase deleteCommunityCommentUseCase; + + private final long communityBoardId = 1L; + private final long communityCommentId = 1L; + + @Test + @DisplayName("커뮤니티 댓글 등록 성공 테스트") + @WithMockCustomUser + void createCommunityComment() throws Exception { + //given + CommunityCommentCreateRequestDto requestDto = CommunityCommentCreateRequestDto.builder() + .content("몇시에 하는지 알 수 있을까요?") + .parentCommentId(null) + .build(); + + MockMultipartFile requestData = new MockMultipartFile( + "data", + "", + MediaType.APPLICATION_JSON_VALUE, + objectMapper.writeValueAsBytes(requestDto) + ); + + given(createCommunityCommentUseCase.createCommunityComment(any(), any(UUID.class), + eq(communityBoardId))).willReturn(communityCommentId); + + //when + mockMvc.perform(multipart("/api/community-board/{board_id}/comment", communityBoardId) + .file(requestData) + .contentType(MULTIPART_FORM_DATA) + .header("Authorization", "Bearer access-token")) + + //then + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(201)) + .andExpect(jsonPath("$.data").value(communityCommentId)) + .andExpect(jsonPath("$.message").value("커뮤니티 댓글 등록 성공")); + } + + @Test + @DisplayName("커뮤니티 댓글 수정 성공 테스트") + @WithMockCustomUser + void updateCommunityComment_success() throws Exception { + //given + CommunityCommentUpdateRequestDto requestDto = CommunityCommentUpdateRequestDto.builder() + .content("감사합니다.") + .build(); + + MockMultipartFile requestData = new MockMultipartFile( + "data", + "", + MediaType.APPLICATION_JSON_VALUE, + objectMapper.writeValueAsBytes(requestDto) + ); + + willDoNothing().given(updateCommunityCommentUseCase) + .updateCommunityComment(any(), any(), + any(UUID.class), any()); + + MockMultipartHttpServletRequestBuilder builder = + multipart("/api/community-board/{board_id}/comment/{id}", communityBoardId, communityCommentId); + builder.with(new RequestPostProcessor() { + @Override + public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { + request.setMethod("PUT"); + return request; + } + }); + + //when + mockMvc.perform(builder + .file(requestData) + .contentType(MULTIPART_FORM_DATA) + .header("Authorization", "Bearer access-token")) + + //then + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andExpect(jsonPath("$.data").isEmpty()) + .andExpect(jsonPath("$.message").value("커뮤니티 댓글 수정 성공")); + } + + @Test + @DisplayName("커뮤니티 댓글 삭제 성공 테스트") + @WithMockCustomUser + void deleteCommunityComment_success() throws Exception { + //given + willDoNothing().given(deleteCommunityCommentUseCase).deleteCommunityComment(any(UUID.class), any(), any()); + + //when + mockMvc.perform(delete("/api/community-board/{board_id}/comment/{id}", communityBoardId, communityCommentId) + .header("Authorization", "Bearer access-token")) + //then + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andExpect(jsonPath("$.message").value("커뮤니티 댓글 삭제 성공")) + .andExpect(jsonPath("$.data").isEmpty()); + } +} diff --git a/src/test/java/com/somemore/community/controller/CommunityCommentQueryApiControllerTest.java b/src/test/java/com/somemore/community/controller/CommunityCommentQueryApiControllerTest.java new file mode 100644 index 000000000..8aa14524f --- /dev/null +++ b/src/test/java/com/somemore/community/controller/CommunityCommentQueryApiControllerTest.java @@ -0,0 +1,57 @@ +package com.somemore.community.controller; + +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.somemore.ControllerTestSupport; +import com.somemore.community.dto.response.CommunityCommentResponseDto; +import java.util.Collections; + +import com.somemore.community.usecase.comment.CommunityCommentQueryUseCase; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; + +public class CommunityCommentQueryApiControllerTest extends ControllerTestSupport { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private CommunityCommentQueryUseCase communityCommentQueryUseCase; + + @Test + @DisplayName("커뮤니티 댓글 조회 성공") + void getByBoardId() throws Exception { + //given + long communityBoardId = 1L; + Page page = new PageImpl<>(Collections.emptyList()); + + given(communityCommentQueryUseCase.getCommunityCommentsByBoardId(any(), anyInt())) + .willReturn(page); + + //when + //then + mockMvc.perform(get("/api/community-board/{board_id}/comments", communityBoardId) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andExpect(jsonPath("$.data").exists()) + .andExpect(jsonPath("$.message") + .value("커뮤니티 게시글의 댓글 리스트 조회 성공")); + + verify(communityCommentQueryUseCase, times(1)) + .getCommunityCommentsByBoardId(any(), anyInt()); + } + +} From d0e5806478badc4a3c30ab9c509156fdab5f9032 Mon Sep 17 00:00:00 2001 From: ayoung-dev Date: Tue, 3 Dec 2024 21:47:38 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat(community):=20community=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=EA=B8=80,=20=EB=8C=93=EA=B8=80=20controller=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 --- .../CommunityBoardCommandApiController.java | 78 +++++++++++++++++++ .../CommunityBoardQueryApiController.java | 61 +++++++++++++++ .../CommunityCommentCommandApiController.java | 69 ++++++++++++++++ .../CommunityCommentQueryApiController.java | 36 +++++++++ 4 files changed, 244 insertions(+) create mode 100644 src/main/java/com/somemore/community/controller/CommunityBoardCommandApiController.java create mode 100644 src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java create mode 100644 src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java create mode 100644 src/main/java/com/somemore/community/controller/CommunityCommentQueryApiController.java diff --git a/src/main/java/com/somemore/community/controller/CommunityBoardCommandApiController.java b/src/main/java/com/somemore/community/controller/CommunityBoardCommandApiController.java new file mode 100644 index 000000000..cbf06ad32 --- /dev/null +++ b/src/main/java/com/somemore/community/controller/CommunityBoardCommandApiController.java @@ -0,0 +1,78 @@ +package com.somemore.community.controller; + +import com.somemore.auth.annotation.CurrentUser; +import com.somemore.community.dto.request.CommunityBoardCreateRequestDto; +import com.somemore.community.dto.request.CommunityBoardUpdateRequestDto; +import com.somemore.community.usecase.board.CreateCommunityBoardUseCase; +import com.somemore.community.usecase.board.DeleteCommunityBoardUseCase; +import com.somemore.community.usecase.board.UpdateCommunityBoardUseCase; +import com.somemore.global.common.response.ApiResponse; +import com.somemore.imageupload.dto.ImageUploadRequestDto; +import com.somemore.imageupload.usecase.ImageUploadUseCase; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.security.access.annotation.Secured; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.UUID; + +import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE; + +@Tag(name = "Community Board Command API", description = "커뮤니티 게시글 생성 수정 삭제 API") +@RequiredArgsConstructor +@RequestMapping("/api/community-board") +@RestController +public class CommunityBoardCommandApiController { + + private final CreateCommunityBoardUseCase createCommunityBoardUseCase; + private final UpdateCommunityBoardUseCase updateCommunityBoardUseCase; + private final DeleteCommunityBoardUseCase deleteCommunityBoardUseCase; + private final ImageUploadUseCase imageUploadUseCase; + + @Secured("ROLE_VOLUNTEER") + @Operation(summary = "커뮤니티 게시글 등록", description = "커뮤니티 게시글을 등록합니다.") + @PostMapping(consumes = MULTIPART_FORM_DATA_VALUE) + public ApiResponse createCommunityBoard( + @CurrentUser UUID user_id, + @Valid @RequestPart("data") CommunityBoardCreateRequestDto requestDto, + @RequestPart(value = "img_file", required = false) MultipartFile image + ) { + String imgUrl = imageUploadUseCase.uploadImage(new ImageUploadRequestDto(image)); + + return ApiResponse.ok( + 201, + createCommunityBoardUseCase.createCommunityBoard(requestDto, user_id, imgUrl), + "커뮤니티 게시글 등록 성공" + ); + } + + @Secured("ROLE_VOLUNTEER") + @Operation(summary = "커뮤니티 게시글 수정", description = "커뮤니티 게시글을 수정합니다.") + @PutMapping(value = "/{id}", consumes = MULTIPART_FORM_DATA_VALUE) + public ApiResponse updateCommunityBoard( + @CurrentUser UUID user_id, + @PathVariable Long id, + @Valid @RequestPart("data") CommunityBoardUpdateRequestDto requestDto, + @RequestPart(value = "img_file", required = false) MultipartFile image + ) { + String imgUrl = imageUploadUseCase.uploadImage(new ImageUploadRequestDto(image)); + updateCommunityBoardUseCase.updateCommunityBoard(requestDto, id, user_id, imgUrl); + + return ApiResponse.ok("커뮤니티 게시글 수정 성공"); + } + + @Secured("ROLE_VOLUNTEER") + @Operation(summary = "커뮤니티 게시글 삭제", description = "커뮤니티 게시글을 삭제합니다.") + @DeleteMapping(value = "/{id}") + public ApiResponse deleteCommunityBoard( + @CurrentUser UUID user_id, + @PathVariable Long id + ) { + deleteCommunityBoardUseCase.deleteCommunityBoard(user_id, id); + + return ApiResponse.ok("커뮤니티 게시글 삭제 성공"); + } +} diff --git a/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java b/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java new file mode 100644 index 000000000..de3316e8f --- /dev/null +++ b/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java @@ -0,0 +1,61 @@ +package com.somemore.community.controller; + +import com.somemore.auth.annotation.CurrentUser; +import com.somemore.community.dto.response.CommunityBoardDetailResponseDto; +import com.somemore.community.dto.response.CommunityBoardResponseDto; +import com.somemore.community.usecase.board.CommunityBoardQueryUseCase; +import com.somemore.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.*; + +import java.util.UUID; + +@Tag(name = "Community Board Query API", description = "커뮤니티 게시글 조회 관련 API") +@RequiredArgsConstructor +@RequestMapping("/api") +@RestController +public class CommunityBoardQueryApiController { + + private final CommunityBoardQueryUseCase communityBoardQueryUseCase; + + @GetMapping("/community-boards") + @Operation(summary = "전체 커뮤니티 게시글 조회", description = "전체 커뮤니티 게시글 목록을 조회합니다.") + public ApiResponse> getAll( + Pageable pageable + ) { + return ApiResponse.ok( + 200, + communityBoardQueryUseCase.getCommunityBoards(pageable.getPageNumber()), + "전체 커뮤니티 게시글 리스트 조회 성공" + ); + } + + @GetMapping("/community-boards/{writer_id}") + @Operation(summary = "작성자별 커뮤니티 게시글 조회", description = "작성자별 커뮤니티 게시글 목록을 조회합니다.") + public ApiResponse> getByWriterId( + @PathVariable @CurrentUser UUID writer_id, + Pageable pageable + ) { + return ApiResponse.ok( + 200, + communityBoardQueryUseCase.getCommunityBoardsByWriterId(writer_id, pageable.getPageNumber()), + "작성자별 커뮤니티 게시글 리스트 조회 성공" + ); + } + + @GetMapping("/community-board/{id}") + @Operation(summary = "커뮤니티 게시글 상세 조회", description = "커뮤니티 게시글의 상세 정보를 조회합니다.") + public ApiResponse getById( + @PathVariable Long id + ) { + return ApiResponse.ok( + 200, + communityBoardQueryUseCase.getCommunityBoardDetail(id), + "커뮤니티 게시글 상세 조회 성공" + ); + } +} diff --git a/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java b/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java new file mode 100644 index 000000000..0f1e129a5 --- /dev/null +++ b/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java @@ -0,0 +1,69 @@ +package com.somemore.community.controller; + +import com.somemore.auth.annotation.CurrentUser; +import com.somemore.community.dto.request.CommunityCommentCreateRequestDto; +import com.somemore.community.dto.request.CommunityCommentUpdateRequestDto; +import com.somemore.community.usecase.comment.CreateCommunityCommentUseCase; +import com.somemore.community.usecase.comment.DeleteCommunityCommentUseCase; +import com.somemore.community.usecase.comment.UpdateCommunityCommentUseCase; +import com.somemore.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.security.access.annotation.Secured; +import org.springframework.web.bind.annotation.*; + +import java.util.UUID; + +@Tag(name = "Community Comment Command API", description = "커뮤니티 댓글 생성 수정 삭제 API") +@RequiredArgsConstructor +@RequestMapping("/api/community-board/{board_id}") +@RestController +public class CommunityCommentCommandApiController { + + private final CreateCommunityCommentUseCase createCommunityCommentUseCase; + private final UpdateCommunityCommentUseCase updateCommunityCommentUseCase; + private final DeleteCommunityCommentUseCase deleteCommunityCommentUseCase; + + @Secured("ROLE_VOLUNTEER") + @Operation(summary = "커뮤니티 댓글 등록", description = "커뮤니티 게시글에 댓글을 등록합니다.") + @PostMapping(value = "/comment") + public ApiResponse createCommunityComment( + @CurrentUser UUID user_id, + @PathVariable Long board_id, + @Valid @RequestPart("data") CommunityCommentCreateRequestDto requestDto) { + + return ApiResponse.ok( + 201, + createCommunityCommentUseCase.createCommunityComment(requestDto, user_id, board_id), + "커뮤니티 댓글 등록 성공"); + } + + @Secured("ROLE_VOLUNTEER") + @Operation(summary = "커뮤니티 댓글 수정", description = "커뮤니티 댓글을 수정합니다.") + @PutMapping(value = "/comment/{id}") + public ApiResponse updateCommunityComment( + @CurrentUser UUID user_id, + @PathVariable Long board_id, + @PathVariable Long id, + @Valid @RequestPart("data") CommunityCommentUpdateRequestDto requestDto + ) { + updateCommunityCommentUseCase.updateCommunityComment(requestDto, id, user_id, board_id); + + return ApiResponse.ok("커뮤니티 댓글 수정 성공"); + } + + @Secured("ROLE_VOLUNTEER") + @Operation(summary = "커뮤니티 댓글 삭제", description = "커뮤니티 댓글을 삭제합니다.") + @DeleteMapping(value = "/comment/{id}") + public ApiResponse deleteCommunityComment( + @CurrentUser UUID user_id, + @PathVariable Long board_id, + @PathVariable Long id + ) { + deleteCommunityCommentUseCase.deleteCommunityComment(user_id, id, board_id); + + return ApiResponse.ok("커뮤니티 댓글 삭제 성공"); + } +} diff --git a/src/main/java/com/somemore/community/controller/CommunityCommentQueryApiController.java b/src/main/java/com/somemore/community/controller/CommunityCommentQueryApiController.java new file mode 100644 index 000000000..094de20e8 --- /dev/null +++ b/src/main/java/com/somemore/community/controller/CommunityCommentQueryApiController.java @@ -0,0 +1,36 @@ +package com.somemore.community.controller; + +import com.somemore.community.dto.response.CommunityCommentResponseDto; +import com.somemore.community.usecase.comment.CommunityCommentQueryUseCase; +import com.somemore.global.common.response.ApiResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "Community Comment Query API", description = "커뮤니티 댓글 조회 API") +@RequiredArgsConstructor +@RequestMapping("/api/community-board") +@RestController +public class CommunityCommentQueryApiController { + + private final CommunityCommentQueryUseCase communityCommentQueryUseCase; + + @GetMapping("/{board_id}/comments") + @Operation(summary = "커뮤니티 댓글 조회", description = "커뮤니티 게시글의 댓글 목록을 조회합니다.") + public ApiResponse> getByBoardId( + @PathVariable Long board_id, + Pageable pageable + ) { + return ApiResponse.ok( + 200, + communityCommentQueryUseCase.getCommunityCommentsByBoardId(board_id, pageable.getPageNumber()), + "커뮤니티 게시글의 댓글 리스트 조회 성공" + ); + } +} From bde087c7c0cbadc0cd7dc07734f4b3dbf5787787 Mon Sep 17 00:00:00 2001 From: ayoung-dev Date: Tue, 3 Dec 2024 21:55:15 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat(community):=20community-comment=20boar?= =?UTF-8?q?dId=20request=20=ED=95=84=EB=93=9C=20->=20Pathvariable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommunityCommentCreateRequestDto.java | 5 +---- .../comment/CreateCommunityCommentService.java | 6 +++--- .../comment/DeleteCommunityCommentService.java | 2 +- .../comment/UpdateCommunityCommentService.java | 4 ++-- .../comment/CreateCommunityCommentUseCase.java | 3 ++- .../comment/DeleteCommunityCommentUseCase.java | 2 +- .../comment/UpdateCommunityCommentUseCase.java | 3 ++- .../CommunityCommentQueryServiceTest.java | 4 ++-- .../CreateCommunityCommentServiceTest.java | 15 +++++---------- .../DeleteCommunityCommentServiceTest.java | 14 +++++++------- .../UpdateCommunityCommentServiceTest.java | 16 ++++++++++------ 11 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/somemore/community/dto/request/CommunityCommentCreateRequestDto.java b/src/main/java/com/somemore/community/dto/request/CommunityCommentCreateRequestDto.java index 2c6a5b104..3ce5792e3 100644 --- a/src/main/java/com/somemore/community/dto/request/CommunityCommentCreateRequestDto.java +++ b/src/main/java/com/somemore/community/dto/request/CommunityCommentCreateRequestDto.java @@ -14,9 +14,6 @@ @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) @Builder public record CommunityCommentCreateRequestDto( - @Schema(description = "커뮤니티 게시글 ID", example = "33") - @NotNull(message = "게시글 ID는 필수 값입니다.") - Long communityBoardId, @Schema(description = "커뮤니티 댓글 내용", example = "저도 함께 하고 싶습니다.") @NotBlank(message = "댓글 내용은 필수 값입니다.") String content, @@ -24,7 +21,7 @@ public record CommunityCommentCreateRequestDto( @Nullable Long parentCommentId ) { - public CommunityComment toEntity(UUID writerId) { + public CommunityComment toEntity(UUID writerId, Long communityBoardId) { return CommunityComment.builder() .communityBoardId(communityBoardId) .writerId(writerId) diff --git a/src/main/java/com/somemore/community/service/comment/CreateCommunityCommentService.java b/src/main/java/com/somemore/community/service/comment/CreateCommunityCommentService.java index ba7a116db..5d3a34d1a 100644 --- a/src/main/java/com/somemore/community/service/comment/CreateCommunityCommentService.java +++ b/src/main/java/com/somemore/community/service/comment/CreateCommunityCommentService.java @@ -24,10 +24,10 @@ public class CreateCommunityCommentService implements CreateCommunityCommentUseC private final CommunityCommentRepository communityCommentRepository; @Override - public Long createCommunityComment(CommunityCommentCreateRequestDto requestDto, UUID writerId) { - CommunityComment communityComment = requestDto.toEntity(writerId); + public Long createCommunityComment(CommunityCommentCreateRequestDto requestDto, UUID writerId, Long communityBoardId) { + CommunityComment communityComment = requestDto.toEntity(writerId, communityBoardId); - validateCommunityBoardExists(communityComment.getCommunityBoardId()); + validateCommunityBoardExists(communityBoardId); if (requestDto.parentCommentId() != null) { validateParentCommentExists(communityComment.getParentCommentId()); diff --git a/src/main/java/com/somemore/community/service/comment/DeleteCommunityCommentService.java b/src/main/java/com/somemore/community/service/comment/DeleteCommunityCommentService.java index 6072c4e4f..03e00e359 100644 --- a/src/main/java/com/somemore/community/service/comment/DeleteCommunityCommentService.java +++ b/src/main/java/com/somemore/community/service/comment/DeleteCommunityCommentService.java @@ -20,7 +20,7 @@ public class DeleteCommunityCommentService implements DeleteCommunityCommentUseC private final CommunityCommentRepository communityCommentRepository; @Override - public void deleteCommunityComment(UUID writerId, Long id) { + public void deleteCommunityComment(UUID writerId, Long id, Long communityBoardId) { CommunityComment communityComment = getCommunityCommentById(id); diff --git a/src/main/java/com/somemore/community/service/comment/UpdateCommunityCommentService.java b/src/main/java/com/somemore/community/service/comment/UpdateCommunityCommentService.java index ec688a9e6..a613c9bcc 100644 --- a/src/main/java/com/somemore/community/service/comment/UpdateCommunityCommentService.java +++ b/src/main/java/com/somemore/community/service/comment/UpdateCommunityCommentService.java @@ -23,11 +23,11 @@ public class UpdateCommunityCommentService implements UpdateCommunityCommentUseC private final CommunityBoardRepository communityBoardRepository; @Override - public void updateCommunityComment(CommunityCommentUpdateRequestDto requestDto, Long communityCommentId, UUID writerId) { + public void updateCommunityComment(CommunityCommentUpdateRequestDto requestDto, Long communityCommentId, UUID writerId, Long communityBoardId) { CommunityComment communityComment = getCommunityCommentById(communityCommentId); - validateCommunityBoardExists(communityComment.getCommunityBoardId()); + validateCommunityBoardExists(communityBoardId); validateWriter(communityComment, writerId); diff --git a/src/main/java/com/somemore/community/usecase/comment/CreateCommunityCommentUseCase.java b/src/main/java/com/somemore/community/usecase/comment/CreateCommunityCommentUseCase.java index 3def6667f..5a2a5ed98 100644 --- a/src/main/java/com/somemore/community/usecase/comment/CreateCommunityCommentUseCase.java +++ b/src/main/java/com/somemore/community/usecase/comment/CreateCommunityCommentUseCase.java @@ -7,5 +7,6 @@ public interface CreateCommunityCommentUseCase { Long createCommunityComment( CommunityCommentCreateRequestDto requestDto, - UUID writerId); + UUID writerId, + Long communityBoardId); } diff --git a/src/main/java/com/somemore/community/usecase/comment/DeleteCommunityCommentUseCase.java b/src/main/java/com/somemore/community/usecase/comment/DeleteCommunityCommentUseCase.java index c5e1f5d38..7226cf348 100644 --- a/src/main/java/com/somemore/community/usecase/comment/DeleteCommunityCommentUseCase.java +++ b/src/main/java/com/somemore/community/usecase/comment/DeleteCommunityCommentUseCase.java @@ -3,5 +3,5 @@ import java.util.UUID; public interface DeleteCommunityCommentUseCase { - void deleteCommunityComment(UUID writerId, Long id); + void deleteCommunityComment(UUID writerId, Long id, Long communityBoardId); } diff --git a/src/main/java/com/somemore/community/usecase/comment/UpdateCommunityCommentUseCase.java b/src/main/java/com/somemore/community/usecase/comment/UpdateCommunityCommentUseCase.java index ef4c028e9..acc15bf41 100644 --- a/src/main/java/com/somemore/community/usecase/comment/UpdateCommunityCommentUseCase.java +++ b/src/main/java/com/somemore/community/usecase/comment/UpdateCommunityCommentUseCase.java @@ -8,5 +8,6 @@ public interface UpdateCommunityCommentUseCase { void updateCommunityComment( CommunityCommentUpdateRequestDto requestDto, Long communityCommentId, - UUID writerId); + UUID writerId, + Long communityBoardId); } diff --git a/src/test/java/com/somemore/community/service/comment/CommunityCommentQueryServiceTest.java b/src/test/java/com/somemore/community/service/comment/CommunityCommentQueryServiceTest.java index 184fc665b..3a1d6034a 100644 --- a/src/test/java/com/somemore/community/service/comment/CommunityCommentQueryServiceTest.java +++ b/src/test/java/com/somemore/community/service/comment/CommunityCommentQueryServiceTest.java @@ -88,7 +88,7 @@ void getCommentsByCommunityBoardId() { @Test void doesNotFind() { //given - deleteCommunityCommentUseCase.deleteCommunityComment(writerId, replyId); + deleteCommunityCommentUseCase.deleteCommunityComment(writerId, replyId, boardId); //when Page comments = communityCommentQueryService.getCommunityCommentsByBoardId(boardId, 0); @@ -105,7 +105,7 @@ void doesNotFind() { void getCommentsByCommunityBoardIdWithDeletedComment() { //given - deleteCommunityCommentUseCase.deleteCommunityComment(writerId, commentId); + deleteCommunityCommentUseCase.deleteCommunityComment(writerId, commentId, boardId); //when Page comments = communityCommentQueryService.getCommunityCommentsByBoardId(boardId, 0); diff --git a/src/test/java/com/somemore/community/service/comment/CreateCommunityCommentServiceTest.java b/src/test/java/com/somemore/community/service/comment/CreateCommunityCommentServiceTest.java index b65a2c2c5..b811cab06 100644 --- a/src/test/java/com/somemore/community/service/comment/CreateCommunityCommentServiceTest.java +++ b/src/test/java/com/somemore/community/service/comment/CreateCommunityCommentServiceTest.java @@ -59,13 +59,12 @@ void createCommunityCommentWithDto() { //given CommunityCommentCreateRequestDto dto = CommunityCommentCreateRequestDto.builder() - .communityBoardId(boardId) .content("커뮤니티 댓글 테스트 내용") .parentCommentId(null) .build(); //when - Long commentId = createCommunityCommentService.createCommunityComment(dto, writerId); + Long commentId = createCommunityCommentService.createCommunityComment(dto, writerId, boardId); //then Optional communityComment = communityCommentRepository.findById(commentId); @@ -83,21 +82,19 @@ void createCommunityCommentRelyWithDto() { //given CommunityCommentCreateRequestDto commentDto = CommunityCommentCreateRequestDto.builder() - .communityBoardId(boardId) .content("커뮤니티 댓글 테스트 내용") .parentCommentId(null) .build(); - Long commentId = createCommunityCommentService.createCommunityComment(commentDto, writerId); + Long commentId = createCommunityCommentService.createCommunityComment(commentDto, writerId, boardId); CommunityCommentCreateRequestDto replyDto = CommunityCommentCreateRequestDto.builder() - .communityBoardId(boardId) .content("커뮤니티 대댓글 테스트 내용") .parentCommentId(commentId) .build(); //when - Long replyCommentId = createCommunityCommentService.createCommunityComment(replyDto, writerId); + Long replyCommentId = createCommunityCommentService.createCommunityComment(replyDto, writerId, boardId); //then Optional communityCommentReply = communityCommentRepository.findById(replyCommentId); @@ -115,13 +112,12 @@ void createCommunityCommentReplyWithDeletedParentId() { //given CommunityCommentCreateRequestDto replyDto = CommunityCommentCreateRequestDto.builder() - .communityBoardId(boardId) .content("커뮤니티 대댓글 테스트 내용") .parentCommentId(2L) .build(); //when - ThrowableAssert.ThrowingCallable callable = () -> createCommunityCommentService.createCommunityComment(replyDto, UUID.randomUUID()); + ThrowableAssert.ThrowingCallable callable = () -> createCommunityCommentService.createCommunityComment(replyDto, UUID.randomUUID(), boardId); //then assertThatExceptionOfType(BadRequestException.class) @@ -135,7 +131,6 @@ void createCommunityCommentWithDeletedBoardId() { //given CommunityCommentCreateRequestDto commentDto = CommunityCommentCreateRequestDto.builder() - .communityBoardId(boardId) .content("커뮤니티 댓글 테스트 내용") .parentCommentId(null) .build(); @@ -143,7 +138,7 @@ void createCommunityCommentWithDeletedBoardId() { communityBoardRepository.deleteAllInBatch(); //when - ThrowableAssert.ThrowingCallable callable = () -> createCommunityCommentService.createCommunityComment(commentDto, UUID.randomUUID()); + ThrowableAssert.ThrowingCallable callable = () -> createCommunityCommentService.createCommunityComment(commentDto, UUID.randomUUID(), boardId); //then assertThatExceptionOfType(BadRequestException.class) diff --git a/src/test/java/com/somemore/community/service/comment/DeleteCommunityCommentServiceTest.java b/src/test/java/com/somemore/community/service/comment/DeleteCommunityCommentServiceTest.java index 2e6db5020..bf159279a 100644 --- a/src/test/java/com/somemore/community/service/comment/DeleteCommunityCommentServiceTest.java +++ b/src/test/java/com/somemore/community/service/comment/DeleteCommunityCommentServiceTest.java @@ -32,7 +32,7 @@ class DeleteCommunityCommentServiceTest extends IntegrationTestSupport { private CommunityBoardRepository communityBoardRepository; private UUID writerId; - private Long commentId; + private Long commentId, boardId; @BeforeEach void setUp() { @@ -44,14 +44,14 @@ void setUp() { writerId = UUID.randomUUID(); CommunityBoard communityBoard = communityBoardRepository.save(boardDto.toEntity(writerId, "https://test.image/123")); + boardId = communityBoard.getId(); CommunityCommentCreateRequestDto dto = CommunityCommentCreateRequestDto.builder() - .communityBoardId(communityBoard.getId()) .content("커뮤니티 댓글 테스트 내용") .parentCommentId(null) .build(); - CommunityComment communityComment = communityCommentRepository.save(dto.toEntity(writerId)); + CommunityComment communityComment = communityCommentRepository.save(dto.toEntity(writerId, communityBoard.getId())); commentId = communityComment.getId();} @@ -66,7 +66,7 @@ void deleteCommunityCommentWithId() { //given //when - deleteCommunityCommentService.deleteCommunityComment(writerId, commentId); + deleteCommunityCommentService.deleteCommunityComment(writerId, commentId, boardId); //then assertThat(communityCommentRepository.existsById(commentId)).isFalse(); @@ -77,10 +77,10 @@ void deleteCommunityCommentWithId() { void deleteCommunityCommentWithDeletedId() { //given - deleteCommunityCommentService.deleteCommunityComment(writerId, commentId); + deleteCommunityCommentService.deleteCommunityComment(writerId, commentId, boardId); //when - ThrowableAssert.ThrowingCallable callable = () -> deleteCommunityCommentService.deleteCommunityComment(writerId, commentId); + ThrowableAssert.ThrowingCallable callable = () -> deleteCommunityCommentService.deleteCommunityComment(writerId, commentId, boardId); //then assertThatExceptionOfType(BadRequestException.class) @@ -94,7 +94,7 @@ void deleteCommunityCommentWithNotWriterId() { //given //when - ThrowableAssert.ThrowingCallable callable = () -> deleteCommunityCommentService.deleteCommunityComment(UUID.randomUUID(), commentId); + ThrowableAssert.ThrowingCallable callable = () -> deleteCommunityCommentService.deleteCommunityComment(UUID.randomUUID(), commentId, boardId); //then assertThatExceptionOfType(BadRequestException.class) diff --git a/src/test/java/com/somemore/community/service/comment/UpdateCommunityCommentServiceTest.java b/src/test/java/com/somemore/community/service/comment/UpdateCommunityCommentServiceTest.java index dfbd16fe3..c86c81177 100644 --- a/src/test/java/com/somemore/community/service/comment/UpdateCommunityCommentServiceTest.java +++ b/src/test/java/com/somemore/community/service/comment/UpdateCommunityCommentServiceTest.java @@ -34,7 +34,7 @@ class UpdateCommunityCommentServiceTest extends IntegrationTestSupport { private CommunityBoardRepository communityBoardRepository; private UUID writerId; - private Long commentId; + private Long commentId, boardId; private CommunityCommentUpdateRequestDto updateRequestDto; @BeforeEach @@ -47,14 +47,14 @@ void setUp() { writerId = UUID.randomUUID(); CommunityBoard communityBoard = communityBoardRepository.save(boardDto.toEntity(writerId, "https://test.image/123")); + boardId = communityBoard.getId(); CommunityCommentCreateRequestDto commentDto = CommunityCommentCreateRequestDto.builder() - .communityBoardId(communityBoard.getId()) .content("커뮤니티 댓글 테스트 내용") .parentCommentId(null) .build(); - CommunityComment communityComment = communityCommentRepository.save(commentDto.toEntity(writerId)); + CommunityComment communityComment = communityCommentRepository.save(commentDto.toEntity(writerId, boardId)); commentId = communityComment.getId(); @@ -74,7 +74,7 @@ void updateCommunityComment() { //given //when - updateCommunityCommentService.updateCommunityComment(updateRequestDto, commentId, writerId); + updateCommunityCommentService.updateCommunityComment(updateRequestDto, commentId, writerId, boardId); //then Optional communityComment = communityCommentRepository.findById(commentId); @@ -89,7 +89,9 @@ void updateCommunityCommentWithNotWriterId() { //given //when - ThrowableAssert.ThrowingCallable callable = () -> updateCommunityCommentService.updateCommunityComment(updateRequestDto, commentId, UUID.randomUUID()); + ThrowableAssert.ThrowingCallable callable = () -> + updateCommunityCommentService.updateCommunityComment(updateRequestDto, commentId, + UUID.randomUUID(), boardId); //then assertThatExceptionOfType(BadRequestException.class) @@ -104,7 +106,9 @@ void updateCommunityCommentWithDeletedBoardId() { //given communityBoardRepository.deleteAllInBatch(); //when - ThrowableAssert.ThrowingCallable callable = () -> updateCommunityCommentService.updateCommunityComment(updateRequestDto, commentId, writerId); + ThrowableAssert.ThrowingCallable callable = () -> + updateCommunityCommentService.updateCommunityComment(updateRequestDto, commentId, + writerId, boardId); //then assertThatExceptionOfType(BadRequestException.class) From 4d51e29c49b679e82508e1cd405b8ba49314d004 Mon Sep 17 00:00:00 2001 From: ayoung-dev Date: Tue, 3 Dec 2024 21:55:56 +0900 Subject: [PATCH 4/8] =?UTF-8?q?feat(community):=20community-comment=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20responseDto=20builder?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/dto/response/CommunityBoardDetailResponseDto.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/somemore/community/dto/response/CommunityBoardDetailResponseDto.java b/src/main/java/com/somemore/community/dto/response/CommunityBoardDetailResponseDto.java index 22a9a28cd..6bab4ff0f 100644 --- a/src/main/java/com/somemore/community/dto/response/CommunityBoardDetailResponseDto.java +++ b/src/main/java/com/somemore/community/dto/response/CommunityBoardDetailResponseDto.java @@ -4,10 +4,12 @@ import com.fasterxml.jackson.databind.annotation.JsonNaming; import com.somemore.community.domain.CommunityBoard; import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; import java.time.LocalDateTime; import java.util.UUID; +@Builder @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) @Schema(description = "커뮤니티 게시글 상세 조회 응답 DTO") public record CommunityBoardDetailResponseDto( From 8247bde825c38c1a637bb1f2c2d3a83261d24c78 Mon Sep 17 00:00:00 2001 From: ayoung-dev Date: Tue, 3 Dec 2024 23:06:22 +0900 Subject: [PATCH 5/8] =?UTF-8?q?refactor(community):=20sonar=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 불필요한 import 제거 - 엔드포인트 snake -> camel --- .../CommunityBoardCommandApiController.java | 12 +++++------ .../CommunityBoardQueryApiController.java | 6 +++--- .../CommunityCommentCommandApiController.java | 20 +++++++++---------- .../CommunityCommentQueryApiController.java | 6 +++--- .../CommunityCommentCreateRequestDto.java | 1 - .../CommunityBoardQueryApiControllerTest.java | 2 +- ...munityCommentCommandApiControllerTest.java | 6 +++--- ...ommunityCommentQueryApiControllerTest.java | 2 +- 8 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/somemore/community/controller/CommunityBoardCommandApiController.java b/src/main/java/com/somemore/community/controller/CommunityBoardCommandApiController.java index cbf06ad32..44ff7957d 100644 --- a/src/main/java/com/somemore/community/controller/CommunityBoardCommandApiController.java +++ b/src/main/java/com/somemore/community/controller/CommunityBoardCommandApiController.java @@ -36,7 +36,7 @@ public class CommunityBoardCommandApiController { @Operation(summary = "커뮤니티 게시글 등록", description = "커뮤니티 게시글을 등록합니다.") @PostMapping(consumes = MULTIPART_FORM_DATA_VALUE) public ApiResponse createCommunityBoard( - @CurrentUser UUID user_id, + @CurrentUser UUID userId, @Valid @RequestPart("data") CommunityBoardCreateRequestDto requestDto, @RequestPart(value = "img_file", required = false) MultipartFile image ) { @@ -44,7 +44,7 @@ public ApiResponse createCommunityBoard( return ApiResponse.ok( 201, - createCommunityBoardUseCase.createCommunityBoard(requestDto, user_id, imgUrl), + createCommunityBoardUseCase.createCommunityBoard(requestDto, userId, imgUrl), "커뮤니티 게시글 등록 성공" ); } @@ -53,13 +53,13 @@ public ApiResponse createCommunityBoard( @Operation(summary = "커뮤니티 게시글 수정", description = "커뮤니티 게시글을 수정합니다.") @PutMapping(value = "/{id}", consumes = MULTIPART_FORM_DATA_VALUE) public ApiResponse updateCommunityBoard( - @CurrentUser UUID user_id, + @CurrentUser UUID userId, @PathVariable Long id, @Valid @RequestPart("data") CommunityBoardUpdateRequestDto requestDto, @RequestPart(value = "img_file", required = false) MultipartFile image ) { String imgUrl = imageUploadUseCase.uploadImage(new ImageUploadRequestDto(image)); - updateCommunityBoardUseCase.updateCommunityBoard(requestDto, id, user_id, imgUrl); + updateCommunityBoardUseCase.updateCommunityBoard(requestDto, id, userId, imgUrl); return ApiResponse.ok("커뮤니티 게시글 수정 성공"); } @@ -68,10 +68,10 @@ public ApiResponse updateCommunityBoard( @Operation(summary = "커뮤니티 게시글 삭제", description = "커뮤니티 게시글을 삭제합니다.") @DeleteMapping(value = "/{id}") public ApiResponse deleteCommunityBoard( - @CurrentUser UUID user_id, + @CurrentUser UUID userId, @PathVariable Long id ) { - deleteCommunityBoardUseCase.deleteCommunityBoard(user_id, id); + deleteCommunityBoardUseCase.deleteCommunityBoard(userId, id); return ApiResponse.ok("커뮤니티 게시글 삭제 성공"); } diff --git a/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java b/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java index de3316e8f..c02305d9b 100644 --- a/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java +++ b/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java @@ -34,15 +34,15 @@ public ApiResponse> getAll( ); } - @GetMapping("/community-boards/{writer_id}") + @GetMapping("/community-boards/{writerId}") @Operation(summary = "작성자별 커뮤니티 게시글 조회", description = "작성자별 커뮤니티 게시글 목록을 조회합니다.") public ApiResponse> getByWriterId( - @PathVariable @CurrentUser UUID writer_id, + @PathVariable @CurrentUser UUID writerId, Pageable pageable ) { return ApiResponse.ok( 200, - communityBoardQueryUseCase.getCommunityBoardsByWriterId(writer_id, pageable.getPageNumber()), + communityBoardQueryUseCase.getCommunityBoardsByWriterId(writerId, pageable.getPageNumber()), "작성자별 커뮤니티 게시글 리스트 조회 성공" ); } diff --git a/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java b/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java index 0f1e129a5..e445419ef 100644 --- a/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java +++ b/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java @@ -18,7 +18,7 @@ @Tag(name = "Community Comment Command API", description = "커뮤니티 댓글 생성 수정 삭제 API") @RequiredArgsConstructor -@RequestMapping("/api/community-board/{board_id}") +@RequestMapping("/api/community-board/{boardId}") @RestController public class CommunityCommentCommandApiController { @@ -30,13 +30,13 @@ public class CommunityCommentCommandApiController { @Operation(summary = "커뮤니티 댓글 등록", description = "커뮤니티 게시글에 댓글을 등록합니다.") @PostMapping(value = "/comment") public ApiResponse createCommunityComment( - @CurrentUser UUID user_id, - @PathVariable Long board_id, + @CurrentUser UUID userId, + @PathVariable Long boardId, @Valid @RequestPart("data") CommunityCommentCreateRequestDto requestDto) { return ApiResponse.ok( 201, - createCommunityCommentUseCase.createCommunityComment(requestDto, user_id, board_id), + createCommunityCommentUseCase.createCommunityComment(requestDto, userId, boardId), "커뮤니티 댓글 등록 성공"); } @@ -44,12 +44,12 @@ public ApiResponse createCommunityComment( @Operation(summary = "커뮤니티 댓글 수정", description = "커뮤니티 댓글을 수정합니다.") @PutMapping(value = "/comment/{id}") public ApiResponse updateCommunityComment( - @CurrentUser UUID user_id, - @PathVariable Long board_id, + @CurrentUser UUID userId, + @PathVariable Long boardId, @PathVariable Long id, @Valid @RequestPart("data") CommunityCommentUpdateRequestDto requestDto ) { - updateCommunityCommentUseCase.updateCommunityComment(requestDto, id, user_id, board_id); + updateCommunityCommentUseCase.updateCommunityComment(requestDto, id, userId, boardId); return ApiResponse.ok("커뮤니티 댓글 수정 성공"); } @@ -58,11 +58,11 @@ public ApiResponse updateCommunityComment( @Operation(summary = "커뮤니티 댓글 삭제", description = "커뮤니티 댓글을 삭제합니다.") @DeleteMapping(value = "/comment/{id}") public ApiResponse deleteCommunityComment( - @CurrentUser UUID user_id, - @PathVariable Long board_id, + @CurrentUser UUID userId, + @PathVariable Long boardId, @PathVariable Long id ) { - deleteCommunityCommentUseCase.deleteCommunityComment(user_id, id, board_id); + deleteCommunityCommentUseCase.deleteCommunityComment(userId, id, boardId); return ApiResponse.ok("커뮤니티 댓글 삭제 성공"); } diff --git a/src/main/java/com/somemore/community/controller/CommunityCommentQueryApiController.java b/src/main/java/com/somemore/community/controller/CommunityCommentQueryApiController.java index 094de20e8..25cec5980 100644 --- a/src/main/java/com/somemore/community/controller/CommunityCommentQueryApiController.java +++ b/src/main/java/com/somemore/community/controller/CommunityCommentQueryApiController.java @@ -21,15 +21,15 @@ public class CommunityCommentQueryApiController { private final CommunityCommentQueryUseCase communityCommentQueryUseCase; - @GetMapping("/{board_id}/comments") + @GetMapping("/{boardId}/comments") @Operation(summary = "커뮤니티 댓글 조회", description = "커뮤니티 게시글의 댓글 목록을 조회합니다.") public ApiResponse> getByBoardId( - @PathVariable Long board_id, + @PathVariable Long boardId, Pageable pageable ) { return ApiResponse.ok( 200, - communityCommentQueryUseCase.getCommunityCommentsByBoardId(board_id, pageable.getPageNumber()), + communityCommentQueryUseCase.getCommunityCommentsByBoardId(boardId, pageable.getPageNumber()), "커뮤니티 게시글의 댓글 리스트 조회 성공" ); } diff --git a/src/main/java/com/somemore/community/dto/request/CommunityCommentCreateRequestDto.java b/src/main/java/com/somemore/community/dto/request/CommunityCommentCreateRequestDto.java index 3ce5792e3..6185bfa44 100644 --- a/src/main/java/com/somemore/community/dto/request/CommunityCommentCreateRequestDto.java +++ b/src/main/java/com/somemore/community/dto/request/CommunityCommentCreateRequestDto.java @@ -6,7 +6,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.annotation.Nullable; import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; import lombok.Builder; import java.util.UUID; diff --git a/src/test/java/com/somemore/community/controller/CommunityBoardQueryApiControllerTest.java b/src/test/java/com/somemore/community/controller/CommunityBoardQueryApiControllerTest.java index 3d2fb8eb6..74e05b775 100644 --- a/src/test/java/com/somemore/community/controller/CommunityBoardQueryApiControllerTest.java +++ b/src/test/java/com/somemore/community/controller/CommunityBoardQueryApiControllerTest.java @@ -67,7 +67,7 @@ void getByWriterId() throws Exception { //when //then - mockMvc.perform(get("/api/community-boards/{writer_id}", writerId) + mockMvc.perform(get("/api/community-boards/{writerId}", writerId) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$.code").value(200)) diff --git a/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java b/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java index e4b7ebd94..36a6063c3 100644 --- a/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java +++ b/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java @@ -71,7 +71,7 @@ void createCommunityComment() throws Exception { eq(communityBoardId))).willReturn(communityCommentId); //when - mockMvc.perform(multipart("/api/community-board/{board_id}/comment", communityBoardId) + mockMvc.perform(multipart("/api/community-board/{boardId}/comment", communityBoardId) .file(requestData) .contentType(MULTIPART_FORM_DATA) .header("Authorization", "Bearer access-token")) @@ -104,7 +104,7 @@ void updateCommunityComment_success() throws Exception { any(UUID.class), any()); MockMultipartHttpServletRequestBuilder builder = - multipart("/api/community-board/{board_id}/comment/{id}", communityBoardId, communityCommentId); + multipart("/api/community-board/{boardId}/comment/{id}", communityBoardId, communityCommentId); builder.with(new RequestPostProcessor() { @Override public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { @@ -134,7 +134,7 @@ void deleteCommunityComment_success() throws Exception { willDoNothing().given(deleteCommunityCommentUseCase).deleteCommunityComment(any(UUID.class), any(), any()); //when - mockMvc.perform(delete("/api/community-board/{board_id}/comment/{id}", communityBoardId, communityCommentId) + mockMvc.perform(delete("/api/community-board/{boardId}/comment/{id}", communityBoardId, communityCommentId) .header("Authorization", "Bearer access-token")) //then .andDo(print()) diff --git a/src/test/java/com/somemore/community/controller/CommunityCommentQueryApiControllerTest.java b/src/test/java/com/somemore/community/controller/CommunityCommentQueryApiControllerTest.java index 8aa14524f..46ea7a9fd 100644 --- a/src/test/java/com/somemore/community/controller/CommunityCommentQueryApiControllerTest.java +++ b/src/test/java/com/somemore/community/controller/CommunityCommentQueryApiControllerTest.java @@ -42,7 +42,7 @@ void getByBoardId() throws Exception { //when //then - mockMvc.perform(get("/api/community-board/{board_id}/comments", communityBoardId) + mockMvc.perform(get("/api/community-board/{boardId}/comments", communityBoardId) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$.code").value(200)) From 0f7ed4798900ed3862209bacfb4386b31496dace Mon Sep 17 00:00:00 2001 From: ayoung-dev Date: Tue, 3 Dec 2024 23:24:15 +0900 Subject: [PATCH 6/8] =?UTF-8?q?refactor(community):=20community=20?= =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=83=9D=EC=84=B1,=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=20requestDto=20@RequestPart("data")=20->=20@RequestBody?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommunityCommentCommandApiController.java | 4 +- ...munityCommentCommandApiControllerTest.java | 49 ++++--------------- 2 files changed, 11 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java b/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java index e445419ef..de3cdab0e 100644 --- a/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java +++ b/src/main/java/com/somemore/community/controller/CommunityCommentCommandApiController.java @@ -32,7 +32,7 @@ public class CommunityCommentCommandApiController { public ApiResponse createCommunityComment( @CurrentUser UUID userId, @PathVariable Long boardId, - @Valid @RequestPart("data") CommunityCommentCreateRequestDto requestDto) { + @Valid @RequestBody CommunityCommentCreateRequestDto requestDto) { return ApiResponse.ok( 201, @@ -47,7 +47,7 @@ public ApiResponse updateCommunityComment( @CurrentUser UUID userId, @PathVariable Long boardId, @PathVariable Long id, - @Valid @RequestPart("data") CommunityCommentUpdateRequestDto requestDto + @Valid @RequestBody CommunityCommentUpdateRequestDto requestDto ) { updateCommunityCommentUseCase.updateCommunityComment(requestDto, id, userId, boardId); diff --git a/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java b/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java index 36a6063c3..1573ba6cc 100644 --- a/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java +++ b/src/test/java/com/somemore/community/controller/CommunityCommentCommandApiControllerTest.java @@ -3,9 +3,7 @@ import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willDoNothing; -import static org.springframework.http.MediaType.MULTIPART_FORM_DATA; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -24,11 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder; -import org.springframework.test.web.servlet.request.RequestPostProcessor; public class CommunityCommentCommandApiControllerTest extends ControllerTestSupport { @@ -60,20 +54,13 @@ void createCommunityComment() throws Exception { .parentCommentId(null) .build(); - MockMultipartFile requestData = new MockMultipartFile( - "data", - "", - MediaType.APPLICATION_JSON_VALUE, - objectMapper.writeValueAsBytes(requestDto) - ); - given(createCommunityCommentUseCase.createCommunityComment(any(), any(UUID.class), eq(communityBoardId))).willReturn(communityCommentId); //when - mockMvc.perform(multipart("/api/community-board/{boardId}/comment", communityBoardId) - .file(requestData) - .contentType(MULTIPART_FORM_DATA) + mockMvc.perform(post("/api/community-board/{boardId}/comment", communityBoardId) + .content(objectMapper.writeValueAsString(requestDto)) + .contentType(MediaType.APPLICATION_JSON) .header("Authorization", "Bearer access-token")) //then @@ -92,32 +79,14 @@ void updateCommunityComment_success() throws Exception { .content("감사합니다.") .build(); - MockMultipartFile requestData = new MockMultipartFile( - "data", - "", - MediaType.APPLICATION_JSON_VALUE, - objectMapper.writeValueAsBytes(requestDto) - ); - willDoNothing().given(updateCommunityCommentUseCase) - .updateCommunityComment(any(), any(), - any(UUID.class), any()); - - MockMultipartHttpServletRequestBuilder builder = - multipart("/api/community-board/{boardId}/comment/{id}", communityBoardId, communityCommentId); - builder.with(new RequestPostProcessor() { - @Override - public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { - request.setMethod("PUT"); - return request; - } - }); + .updateCommunityComment(any(), any(), any(UUID.class), any()); //when - mockMvc.perform(builder - .file(requestData) - .contentType(MULTIPART_FORM_DATA) - .header("Authorization", "Bearer access-token")) + mockMvc.perform(put("/api/community-board/{boardId}/comment/{id}", communityBoardId, communityCommentId) + .content(objectMapper.writeValueAsString(requestDto)) + .contentType(MediaType.APPLICATION_JSON) + .header("Authorization", "Bearer access-token")) //then .andExpect(status().isOk()) From 82f20f0e1fb35de28095556ee22d0ec31c760a16 Mon Sep 17 00:00:00 2001 From: ayoung-dev Date: Wed, 4 Dec 2024 09:27:43 +0900 Subject: [PATCH 7/8] =?UTF-8?q?refactor(community):=20community=20?= =?UTF-8?q?=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EC=A1=B0=ED=9A=8C=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20@CurrentUser=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/controller/CommunityBoardQueryApiController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java b/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java index c02305d9b..6d9ccdc95 100644 --- a/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java +++ b/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java @@ -37,7 +37,7 @@ public ApiResponse> getAll( @GetMapping("/community-boards/{writerId}") @Operation(summary = "작성자별 커뮤니티 게시글 조회", description = "작성자별 커뮤니티 게시글 목록을 조회합니다.") public ApiResponse> getByWriterId( - @PathVariable @CurrentUser UUID writerId, + @PathVariable UUID writerId, Pageable pageable ) { return ApiResponse.ok( From 58e37d40bb91824692503226f265bb3aeea0af75 Mon Sep 17 00:00:00 2001 From: ayoung-dev Date: Wed, 4 Dec 2024 09:33:17 +0900 Subject: [PATCH 8/8] =?UTF-8?q?chore(community):=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/controller/CommunityBoardQueryApiController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java b/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java index 6d9ccdc95..18f112412 100644 --- a/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java +++ b/src/main/java/com/somemore/community/controller/CommunityBoardQueryApiController.java @@ -1,6 +1,5 @@ package com.somemore.community.controller; -import com.somemore.auth.annotation.CurrentUser; import com.somemore.community.dto.response.CommunityBoardDetailResponseDto; import com.somemore.community.dto.response.CommunityBoardResponseDto; import com.somemore.community.usecase.board.CommunityBoardQueryUseCase;