Skip to content

Commit

Permalink
Merge pull request #124 from dnd-side-project/feat/#122
Browse files Browse the repository at this point in the history
feat: ์„ค๋ฌธ ๋‹จ์ผ ์กฐํšŒ ์‹œ questionName ํ•„๋“œ ์ถ”๊ฐ€(#122)
  • Loading branch information
eun-seong authored Mar 17, 2024
2 parents b4373e9 + dab8b5f commit b05f59d
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.dnd.namuiwiki.common.exception.ApplicationErrorType;
import com.dnd.namuiwiki.domain.option.entity.Option;
import com.dnd.namuiwiki.domain.question.entity.Question;
import com.dnd.namuiwiki.domain.question.type.QuestionName;
import com.dnd.namuiwiki.domain.survey.model.entity.Answer;
import com.dnd.namuiwiki.domain.survey.model.entity.Survey;
import com.dnd.namuiwiki.domain.survey.type.AnswerType;
Expand Down Expand Up @@ -34,14 +35,27 @@ private static class SingleQuestionAndAnswer {
private String text;
private Object value;
private String reason;
private QuestionName questionName;

static SingleQuestionAndAnswer from(Question question, Answer surveyAnswer) {
if (surveyAnswer.getType().equals(AnswerType.MANUAL)) {
return new SingleQuestionAndAnswer(question.getTitle(), surveyAnswer.getAnswer().toString(), surveyAnswer.getAnswer(), surveyAnswer.getReason());
return new SingleQuestionAndAnswer(
question.getTitle(),
surveyAnswer.getAnswer().toString(),
surveyAnswer.getAnswer(),
surveyAnswer.getReason(),
question.getName()
);
}
Option option = question.getOption(surveyAnswer.getAnswer().toString())
.orElseThrow(() -> new ApplicationErrorException(ApplicationErrorType.INVALID_OPTION_ID));
return new SingleQuestionAndAnswer(question.getTitle(), option.getText(), option.getValue(), surveyAnswer.getReason());
return new SingleQuestionAndAnswer(
question.getTitle(),
option.getText(),
option.getValue(),
surveyAnswer.getReason(),
question.getName()
);
}
}

Expand Down

0 comments on commit b05f59d

Please sign in to comment.