diff --git a/src/main/java/com/sendback/domain/feedback/dto/response/FeedbackDetailResponseDto.java b/src/main/java/com/sendback/domain/feedback/dto/response/FeedbackDetailResponseDto.java index 31bd1ed..d0e6d7f 100644 --- a/src/main/java/com/sendback/domain/feedback/dto/response/FeedbackDetailResponseDto.java +++ b/src/main/java/com/sendback/domain/feedback/dto/response/FeedbackDetailResponseDto.java @@ -49,7 +49,7 @@ public static FeedbackDetailResponseDto from(Feedback feedback) { project.getId(), project.getTitle(), project.getFieldName().getName(), - project.getProgress().toString() + project.getProgress().getValue() ); } } diff --git a/src/main/java/com/sendback/domain/feedback/dto/response/FeedbackResponseDto.java b/src/main/java/com/sendback/domain/feedback/dto/response/FeedbackResponseDto.java index dddc1c6..062f847 100644 --- a/src/main/java/com/sendback/domain/feedback/dto/response/FeedbackResponseDto.java +++ b/src/main/java/com/sendback/domain/feedback/dto/response/FeedbackResponseDto.java @@ -14,10 +14,9 @@ public record FeedbackResponseDto( @JsonFormat(pattern = "yyyy.MM.dd") LocalDate endedAt, boolean isFinished, - boolean isAuthor, boolean isSubmitted ) { - public static FeedbackResponseDto of(Feedback feedback, boolean isAuthor, boolean isSubmitted) { + public static FeedbackResponseDto of(Feedback feedback, boolean isSubmitted) { return new FeedbackResponseDto( feedback.getId(), feedback.getTitle(), @@ -25,7 +24,6 @@ public static FeedbackResponseDto of(Feedback feedback, boolean isAuthor, boolea feedback.getStartedAt(), feedback.getEndedAt(), feedback.isFinished(), - isAuthor, isSubmitted ); } diff --git a/src/main/java/com/sendback/domain/feedback/dto/response/GetFeedbacksResponse.java b/src/main/java/com/sendback/domain/feedback/dto/response/GetFeedbacksResponse.java index 28261ea..131139c 100644 --- a/src/main/java/com/sendback/domain/feedback/dto/response/GetFeedbacksResponse.java +++ b/src/main/java/com/sendback/domain/feedback/dto/response/GetFeedbacksResponse.java @@ -3,5 +3,6 @@ import java.util.List; public record GetFeedbacksResponse( - List feedbacks + List feedbacks, + boolean isAuthor ) {} \ No newline at end of file diff --git a/src/main/java/com/sendback/domain/feedback/service/FeedbackService.java b/src/main/java/com/sendback/domain/feedback/service/FeedbackService.java index 6a12264..0bee7c3 100644 --- a/src/main/java/com/sendback/domain/feedback/service/FeedbackService.java +++ b/src/main/java/com/sendback/domain/feedback/service/FeedbackService.java @@ -61,18 +61,18 @@ public GetFeedbacksResponse getFeedbacks(Long userId, Long projectId) { if (userId == null) { List feedbackResponsDtos = feedbacks.stream() - .map(feedback -> FeedbackResponseDto.of(feedback, false, false)).toList(); - return new GetFeedbacksResponse(feedbackResponsDtos); + .map(feedback -> FeedbackResponseDto.of(feedback, false)).toList(); + return new GetFeedbacksResponse(feedbackResponsDtos, false); } User loginUser = userService.getUserById(userId); boolean isAuthor = project.isAuthor(loginUser); List feedbackResponsDtos = feedbacks.stream() - .map(feedback -> FeedbackResponseDto.of(feedback, isAuthor, checkSubmit(loginUser, feedback))) + .map(feedback -> FeedbackResponseDto.of(feedback, checkSubmit(loginUser, feedback))) .toList(); - return new GetFeedbacksResponse(feedbackResponsDtos); + return new GetFeedbacksResponse(feedbackResponsDtos, isAuthor); } private boolean checkSubmit(User loginUser, Feedback feedback) { diff --git a/src/main/java/com/sendback/domain/project/controller/ProjectController.java b/src/main/java/com/sendback/domain/project/controller/ProjectController.java index d09aecb..ba22f75 100644 --- a/src/main/java/com/sendback/domain/project/controller/ProjectController.java +++ b/src/main/java/com/sendback/domain/project/controller/ProjectController.java @@ -37,7 +37,7 @@ public ApiResponse> getProjects( @PageableDefault(page = 1, size = 5) Pageable pageable, @RequestParam(required = false) String keyword, @RequestParam(required = false) String field, - @RequestParam(name = "is-finished", required = false) Boolean isFinished, + @RequestParam(required = false) Boolean isFinished, @RequestParam(required = false) Long sort ) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); diff --git a/src/test/java/com/sendback/domain/feedback/controller/FeedbackControllerTest.java b/src/test/java/com/sendback/domain/feedback/controller/FeedbackControllerTest.java index 0ed8dc3..1065a0f 100644 --- a/src/test/java/com/sendback/domain/feedback/controller/FeedbackControllerTest.java +++ b/src/test/java/com/sendback/domain/feedback/controller/FeedbackControllerTest.java @@ -270,6 +270,7 @@ public void success() throws Exception { .description("코드"), fieldWithPath("data").type(JsonFieldType.OBJECT).description("데이터"), fieldWithPath("data.feedbacks").type(JsonFieldType.ARRAY).description("피드백 리스트"), + fieldWithPath("data.isAuthor").type(JsonFieldType.BOOLEAN).description("작성자 여부"), fieldWithPath("data.feedbacks[].feedbackId").type(JsonFieldType.NUMBER).description("피드백 ID"), fieldWithPath("data.feedbacks[].title").type(JsonFieldType.STRING).description("제목"), fieldWithPath("data.feedbacks[].rewardMessage").type(JsonFieldType.STRING).description("추가 리워드"), @@ -278,7 +279,6 @@ public void success() throws Exception { fieldWithPath("data.feedbacks[].endedAt").type(JsonFieldType.STRING).description("끝나는 날짜") .attributes(Attributes.key("format").value("yyyy.MM.dd")), fieldWithPath("data.feedbacks[].isFinished").type(JsonFieldType.BOOLEAN).description("피드백 종료 여부"), - fieldWithPath("data.feedbacks[].isAuthor").type(JsonFieldType.BOOLEAN).description("작성자 여부"), fieldWithPath("data.feedbacks[].isSubmitted").type(JsonFieldType.BOOLEAN).description("제출 여부"), fieldWithPath("message").type(JsonFieldType.STRING) .description("메시지") @@ -286,13 +286,13 @@ public void success() throws Exception { .andExpect(jsonPath("$.code").value("200")) .andExpect(jsonPath("$.message").value("성공")) .andExpect(jsonPath("$.data.feedbacks").isArray()) + .andExpect(jsonPath("$.data.isAuthor").value(false)) .andExpect(jsonPath("$.data.feedbacks[0].feedbackId").value(MOCK_FEEDBACK_RESPONSE_DTO_A.feedbackId())) .andExpect(jsonPath("$.data.feedbacks[0].title").value(MOCK_FEEDBACK_RESPONSE_DTO_A.title())) .andExpect(jsonPath("$.data.feedbacks[0].rewardMessage").value(MOCK_FEEDBACK_RESPONSE_DTO_A.rewardMessage())) .andExpect(jsonPath("$.data.feedbacks[0].startedAt").value(MOCK_FEEDBACK_RESPONSE_DTO_A.startedAt().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")))) .andExpect(jsonPath("$.data.feedbacks[0].endedAt").value(MOCK_FEEDBACK_RESPONSE_DTO_A.endedAt().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")))) .andExpect(jsonPath("$.data.feedbacks[0].isFinished").value(MOCK_FEEDBACK_RESPONSE_DTO_A.isFinished())) - .andExpect(jsonPath("$.data.feedbacks[0].isAuthor").value(MOCK_FEEDBACK_RESPONSE_DTO_A.isAuthor())) .andExpect(jsonPath("$.data.feedbacks[0].isSubmitted").value(MOCK_FEEDBACK_RESPONSE_DTO_A.isSubmitted())) .andExpect(jsonPath("$.data.feedbacks[1].feedbackId").value(MOCK_FEEDBACK_RESPONSE_DTO_B.feedbackId())) .andExpect(jsonPath("$.data.feedbacks[1].title").value(MOCK_FEEDBACK_RESPONSE_DTO_B.title())) @@ -300,7 +300,6 @@ public void success() throws Exception { .andExpect(jsonPath("$.data.feedbacks[1].startedAt").value(MOCK_FEEDBACK_RESPONSE_DTO_B.startedAt().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")))) .andExpect(jsonPath("$.data.feedbacks[1].endedAt").value(MOCK_FEEDBACK_RESPONSE_DTO_B.endedAt().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")))) .andExpect(jsonPath("$.data.feedbacks[1].isFinished").value(MOCK_FEEDBACK_RESPONSE_DTO_B.isFinished())) - .andExpect(jsonPath("$.data.feedbacks[1].isAuthor").value(MOCK_FEEDBACK_RESPONSE_DTO_B.isAuthor())) .andExpect(jsonPath("$.data.feedbacks[1].isSubmitted").value(MOCK_FEEDBACK_RESPONSE_DTO_B.isSubmitted())) .andExpect(status().isOk()); } diff --git a/src/test/java/com/sendback/domain/feedback/fixture/FeedbackFixture.java b/src/test/java/com/sendback/domain/feedback/fixture/FeedbackFixture.java index 4f5fd1d..5b9a66e 100644 --- a/src/test/java/com/sendback/domain/feedback/fixture/FeedbackFixture.java +++ b/src/test/java/com/sendback/domain/feedback/fixture/FeedbackFixture.java @@ -42,17 +42,17 @@ public class FeedbackFixture { public static final FeedbackResponseDto MOCK_FEEDBACK_RESPONSE_DTO_A = new FeedbackResponseDto( 1L, "기획 피드백 부탁해요", "아메리카노 5개", LocalDate.of(2024, 1, 12), - LocalDate.of(2024, 1, 15), false, false, false + LocalDate.of(2024, 1, 15), false, false ); public static final FeedbackResponseDto MOCK_FEEDBACK_RESPONSE_DTO_B = new FeedbackResponseDto( 2L, "와이어 프레임 피드백 부탁해요", "빙수 5개", LocalDate.of(2024, 1, 15), - LocalDate.of(2024, 1, 18), true, true, false + LocalDate.of(2024, 1, 18), true, true ); public static final GetFeedbacksResponse MOCK_GET_FEEDBACK_RESPONSE = new GetFeedbacksResponse( - List.of(MOCK_FEEDBACK_RESPONSE_DTO_A, MOCK_FEEDBACK_RESPONSE_DTO_B) + List.of(MOCK_FEEDBACK_RESPONSE_DTO_A, MOCK_FEEDBACK_RESPONSE_DTO_B), false ); public static FeedbackSubmit createDummyFeedbackSubmit(User user, Feedback feedback) { diff --git a/src/test/java/com/sendback/domain/feedback/service/FeedbackServiceTest.java b/src/test/java/com/sendback/domain/feedback/service/FeedbackServiceTest.java index 6a52f29..aa30577 100644 --- a/src/test/java/com/sendback/domain/feedback/service/FeedbackServiceTest.java +++ b/src/test/java/com/sendback/domain/feedback/service/FeedbackServiceTest.java @@ -90,7 +90,6 @@ public void success_anonymous() throws Exception { assertThat(feedbackResponseDto.feedbackId()).isEqualTo(1L); assertThat(feedbackResponseDto.title()).isEqualTo(feedback.getTitle()); assertThat(feedbackResponseDto.rewardMessage()).isEqualTo(feedback.getRewardMessage()); - assertThat(feedbackResponseDto.isAuthor()).isEqualTo(false); assertThat(feedbackResponseDto.isSubmitted()).isEqualTo(false); } @@ -115,10 +114,8 @@ public void success() throws Exception { assertThat(feedbackResponseDto.feedbackId()).isEqualTo(1L); assertThat(feedbackResponseDto.title()).isEqualTo(feedback.getTitle()); assertThat(feedbackResponseDto.rewardMessage()).isEqualTo(feedback.getRewardMessage()); - assertThat(feedbackResponseDto.isAuthor()).isEqualTo(true); assertThat(feedbackResponseDto.isSubmitted()).isEqualTo(true); - } } diff --git a/src/test/java/com/sendback/domain/project/controller/ProjectControllerTest.java b/src/test/java/com/sendback/domain/project/controller/ProjectControllerTest.java index d952ab1..e8775f9 100644 --- a/src/test/java/com/sendback/domain/project/controller/ProjectControllerTest.java +++ b/src/test/java/com/sendback/domain/project/controller/ProjectControllerTest.java @@ -51,6 +51,7 @@ public class ProjectControllerTest extends ControllerTest { class getProjects { GetProjectsResponseDto getProjectsResponseDto = MOCK_GET_PROJECTS_RESPONSE_DTO; + @Test @WithMockCustomUser @DisplayName("정상적인 요청일 시 성공을 반환한다.") @@ -75,7 +76,7 @@ public void success() throws Exception { .param("size", "5") .param("keyword", "재미있는") .param("field", "게임") - .param("is-finished", "true") + .param("isFinished", "true") .param("sort", "0")) .andDo(print()); @@ -89,7 +90,7 @@ public void success() throws Exception { parameterWithName("size").description("사이즈"), parameterWithName("keyword").description("검색 키워드"), parameterWithName("field").description("분야"), - parameterWithName("is-finished").description("종료 여부"), + parameterWithName("isFinished").description("종료 여부"), parameterWithName("sort").description("정렬 기준") ),