Skip to content

Commit

Permalink
Merge pull request #138 from dnd-side-project/dev
Browse files Browse the repository at this point in the history
release v0.2.7
  • Loading branch information
eun-seong authored Mar 19, 2024
2 parents 66ad20a + c79b488 commit e0dbd97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/main/java/com/dnd/namuiwiki/domain/survey/SurveyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public GetAnswersByQuestionResponse getAnswersByQuestion(String wikiId, String q
.period(survey.getPeriod())
.relation(survey.getRelation())
.createdAt(survey.getWrittenAt())
.answer(convertAnswerToText(question, answerOfQuestion))
.answer(convertAnswer(question, answerOfQuestion))
.reason(answerOfQuestion.getReason())
.optionName(question, answerOfQuestion)
.build();
Expand Down Expand Up @@ -177,12 +177,16 @@ private Page<Survey> getReceivedSurveysByFilter(Period period, Relation relation
return surveyRepository.findByOwner(owner, pageable);
}

private String convertAnswerToText(Question question, Answer answer) {
private Object convertAnswer(Question question, Answer answer) {
if (answer.getType().equals(AnswerType.MANUAL)) {
return answer.getAnswer().toString();
return answer.getAnswer();
}

Option option = question.getOption(answer.getAnswer().toString())
.orElseThrow(() -> new ApplicationErrorException(ApplicationErrorType.INVALID_OPTION_ID));
if (question.getType().isNumericType()) {
return option.getValue();
}
return option.getText();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SingleAnswerWithSurveyDetailDto {
private Period period;
private Relation relation;
private LocalDateTime createdAt;
private String answer;
private Object answer;
private String reason;
private String optionName;

Expand Down

0 comments on commit e0dbd97

Please sign in to comment.