Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] refactor: 리뷰 상세 조회 dto 개선 #847

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

public record OptionItemAnswerResponse(
long optionId,
String content,
boolean isChecked
String content
) {
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package reviewme.review.service.dto.response.detail;

import jakarta.annotation.Nullable;
import java.util.List;
import reviewme.question.domain.QuestionType;

public record QuestionAnswerResponse(
long questionId,
boolean required,
QuestionType questionType,
String content,
@Nullable OptionGroupAnswerResponse optionGroup,
@Nullable List<OptionItemAnswerResponse> options,
@Nullable String answer
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ public record SectionAnswerResponse(
String header,
List<QuestionAnswerResponse> questions
) {

public boolean hasAnsweredQuestion() {
return !questions.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import reviewme.review.domain.CheckboxAnswerSelectedOption;
import reviewme.review.domain.Review;
import reviewme.review.domain.TextAnswer;
import reviewme.review.service.dto.response.detail.OptionGroupAnswerResponse;
import reviewme.review.service.dto.response.detail.OptionItemAnswerResponse;
import reviewme.review.service.dto.response.detail.QuestionAnswerResponse;
import reviewme.review.service.dto.response.detail.ReviewDetailResponse;
Expand Down Expand Up @@ -107,22 +106,15 @@ private QuestionAnswerResponse mapToCheckboxQuestionResponse(Review review,

List<OptionItemAnswerResponse> optionItemResponse = optionItems.stream()
.filter(optionItem -> selectedOptionIds.contains(optionItem.getId()))
.map(optionItem -> new OptionItemAnswerResponse(optionItem.getId(), optionItem.getContent(), true))
.map(optionItem -> new OptionItemAnswerResponse(optionItem.getId(), optionItem.getContent()))
.toList();

OptionGroupAnswerResponse optionGroupAnswerResponse = new OptionGroupAnswerResponse(
optionGroup.getId(),
optionGroup.getMinSelectionCount(),
optionGroup.getMaxSelectionCount(),
optionItemResponse
);

return new QuestionAnswerResponse(
question.getId(),
question.isRequired(),
question.getQuestionType(),
question.getContent(),
optionGroupAnswerResponse,
optionItemResponse,
null
);
}
Expand Down
12 changes: 3 additions & 9 deletions backend/src/test/java/reviewme/api/ReviewApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,9 @@ class ReviewApiTest extends ApiTest {
fieldWithPath("sections[].questions[].content").description("질문 내용"),
fieldWithPath("sections[].questions[].questionType").description("질문 타입"),

fieldWithPath("sections[].questions[].optionGroup").description("옵션 그룹").optional(),
fieldWithPath("sections[].questions[].optionGroup.optionGroupId").description("옵션 그룹 ID"),
fieldWithPath("sections[].questions[].optionGroup.minCount").description("최소 선택 개수"),
fieldWithPath("sections[].questions[].optionGroup.maxCount").description("최대 선택 개수"),

fieldWithPath("sections[].questions[].optionGroup.options[]").description("선택 항목 목록"),
fieldWithPath("sections[].questions[].optionGroup.options[].optionId").description("선택 항목 ID"),
fieldWithPath("sections[].questions[].optionGroup.options[].content").description("선택 항목 내용"),
fieldWithPath("sections[].questions[].optionGroup.options[].isChecked").description("선택 여부"),
fieldWithPath("sections[].questions[].options[]").description("선택 항목 목록"),
fieldWithPath("sections[].questions[].options[].optionId").description("선택 항목 ID"),
fieldWithPath("sections[].questions[].options[].content").description("선택 항목 내용"),
fieldWithPath("sections[].questions[].answer").description("서술형 답변").optional(),
};

Expand Down
21 changes: 9 additions & 12 deletions backend/src/test/java/reviewme/api/TemplateFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import java.time.LocalDate;
import java.util.List;
import reviewme.question.domain.QuestionType;
import reviewme.review.service.dto.response.detail.OptionGroupAnswerResponse;
import reviewme.review.service.dto.response.detail.OptionItemAnswerResponse;
import reviewme.review.service.dto.response.detail.QuestionAnswerResponse;
import reviewme.review.service.dto.response.detail.SectionAnswerResponse;
import reviewme.review.service.dto.response.detail.ReviewDetailResponse;
import reviewme.review.service.dto.response.detail.SectionAnswerResponse;
import reviewme.template.domain.VisibleType;
import reviewme.template.service.dto.response.OptionGroupResponse;
import reviewme.template.service.dto.response.OptionItemResponse;
Expand Down Expand Up @@ -75,27 +74,25 @@ public static TemplateResponse templateResponse() {
public static ReviewDetailResponse templateAnswerResponse() {
// Section 1
List<OptionItemAnswerResponse> firstOptionAnswers = List.of(
new OptionItemAnswerResponse(1, "커뮤니케이션, 협업 능력 (ex: 팀원간의 원활한 정보 공유, 명확한 의사소통)", true),
new OptionItemAnswerResponse(2, "문제 해결 능력 (ex: 프로젝트 중 만난 버그/오류를 분석하고 이를 해결하는 능력)", false),
new OptionItemAnswerResponse(3, "시간 관리 능력 (ex: 일정과 마감 기한 준수, 업무의 우선 순위 분배)", false)
new OptionItemAnswerResponse(1, "커뮤니케이션, 협업 능력 (ex: 팀원간의 원활한 정보 공유, 명확한 의사소통)"),
new OptionItemAnswerResponse(2, "문제 해결 능력 (ex: 프로젝트 중 만난 버그/오류를 분석하고 이를 해결하는 능력)"),
new OptionItemAnswerResponse(3, "시간 관리 능력 (ex: 일정과 마감 기한 준수, 업무의 우선 순위 분배)")
);
OptionGroupAnswerResponse firstOptionGroupAnswer = new OptionGroupAnswerResponse(1, 1, 2, firstOptionAnswers);
QuestionAnswerResponse firstQuestionAnswer = new QuestionAnswerResponse(
1, true, QuestionType.CHECKBOX, "프로젝트 기간 동안, 아루의 강점이 드러났던 순간을 선택해주세요.", firstOptionGroupAnswer, null
1, true, QuestionType.CHECKBOX, "프로젝트 기간 동안, 아루의 강점이 드러났던 순간을 선택해주세요.", firstOptionAnswers, null
);
SectionAnswerResponse firstSectionAnswer = new SectionAnswerResponse(
1, "프로젝트 기간 동안, 아루의 강점이 드러났던 순간을 선택해주세요.", List.of(firstQuestionAnswer)
);

// Section 2
List<OptionItemAnswerResponse> secondOptionAnswers = List.of(
new OptionItemAnswerResponse(4, "반대 의견을 내더라도 듣는 사람이 기분 나쁘지 않게 이야기해요.", true),
new OptionItemAnswerResponse(5, "팀원들의 의견을 잘 모아서 회의가 매끄럽게 진행되도록 해요.", false),
new OptionItemAnswerResponse(6, "팀의 분위기를 주도해요.", true)
new OptionItemAnswerResponse(4, "반대 의견을 내더라도 듣는 사람이 기분 나쁘지 않게 이야기해요."),
new OptionItemAnswerResponse(5, "팀원들의 의견을 잘 모아서 회의가 매끄럽게 진행되도록 해요."),
new OptionItemAnswerResponse(6, "팀의 분위기를 주도해요.")
);
OptionGroupAnswerResponse secondOptionGroupAnswer = new OptionGroupAnswerResponse(2, 1, 3, secondOptionAnswers);
QuestionAnswerResponse secondQuestionAnswer = new QuestionAnswerResponse(
2, true, QuestionType.CHECKBOX, "커뮤니케이션, 협업 능력에서 어떤 부분이 인상 깊었는지 선택해주세요.", secondOptionGroupAnswer,
2, true, QuestionType.CHECKBOX, "커뮤니케이션, 협업 능력에서 어떤 부분이 인상 깊었는지 선택해주세요.", secondOptionAnswers,
null
);
SectionAnswerResponse secondSectionAnswer = new SectionAnswerResponse(
Expand Down