Skip to content

Commit

Permalink
Merge pull request #39 from KusitmsHDmedi/feature/38-survey
Browse files Browse the repository at this point in the history
[fix] api 정상 플로우 테스트
  • Loading branch information
sebbbin authored Sep 16, 2023
2 parents e1fae97 + 0ba6d27 commit 5d8e957
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ResponseEntity<BaseResponse<?>> submitSurvey(@AuthenticatedUserId final H
public ResponseEntity<BaseResponse<?>> getAllSurveys(@AuthenticatedUserId final HDmediUser hDmediUser) {
final AllSurveyResponseDto responseDto = surveyService.getAllSurvey(hDmediUser);
return ResponseEntity.status(HttpStatus.OK)
.body(BaseResponse.of(SuccessCode.OK, null));
.body(BaseResponse.of(SuccessCode.OK, responseDto));
}

@GetMapping("/result")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
import lombok.Builder;
import lombok.Data;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Builder
@Data
public class Respondent extends BaseTimeEntity {
public class Respondent{
private List<BaseSurvey> baseSurveyList;
private int totalScore;
private LocalDate createDate;

public static Respondent createRespondent(List<BaseSurvey> baseSurveyList, int totalScore) {
public static Respondent createRespondent(List<BaseSurvey> baseSurveyList, int totalScore, LocalDate localDate) {
return Respondent.builder()
.baseSurveyList(baseSurveyList)
.totalScore(totalScore)
.createDate(localDate)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand All @@ -26,7 +27,7 @@ public class SurveyService {

public SurveyResultResponseDto processSurvey(HDmediUser hDmediUser, CreateSurveyDto createSurveyDto) {
List<BaseSurvey> baseSurveyList = createBaseSurvey(createSurveyDto.getQuestionList());
Respondent respondent = Respondent.createRespondent(baseSurveyList, createSurveyDto.getTotalScore());
Respondent respondent = Respondent.createRespondent(baseSurveyList, createSurveyDto.getTotalScore(), LocalDate.now());
Survey currentSurvey = findSurvey(hDmediUser.getId());
addRespondentSurvey(hDmediUser.getIsGuest(), currentSurvey, respondent);
saveSurvey(currentSurvey);
Expand Down Expand Up @@ -62,14 +63,13 @@ private List<BaseAllSurveyResponseDto> getBaseAllSurveyResponseDtoList(Survey cu
List<Respondent> respondentList = currentSurvey.getEachSurvey().getParentsSurveyList();
List<BaseAllSurveyResponseDto> responseDtoList = IntStream.range(0, respondentList.size())
.mapToObj(idx -> BaseAllSurveyResponseDto.of(
respondentList.get(idx).getLastModifiedDate().toLocalDate(),
respondentList.get(idx).getCreateDate(),
Long.valueOf(idx)
))
.collect(Collectors.toList());
return responseDtoList;
}


private List<BaseSurveyResponseDto> getBaseSurveyDtoListFor(Respondent respondent) {
return respondent.getBaseSurveyList().stream()
.map(baseSurvey ->
Expand All @@ -94,7 +94,7 @@ private Respondent getParentsRespondent(Survey currentSurvey, int id) {

private Respondent getTeacherRespondent(Survey currentSurvey, int id) {
List<Respondent> teacherSurveyList = currentSurvey.getEachSurvey().getTeacherSurveyList();
if (teacherSurveyList.size() <= id) return Respondent.createRespondent(null, -1);
if (teacherSurveyList.size() <= id) return Respondent.createRespondent(null, -1, LocalDate.now());
return teacherSurveyList.get(id);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/messages_ko_KR.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
emergency.content = ????? ? ???? ??? ???? ????. ??? ?? ???? ??? ????? ????? ??? ?? ??? ?? ?? ???? ?? ?? ????? ???? ??? ??? ??? ??? ???? ??? ??? ?? ???? ??? ?? ?? ????.
non.emergency.content = ?? ??? ?? ????. ??? ??? ???? ??? ??? ?? ? ???? ???? ??? ??? ?? ?? ??????. ADHD? ?? ? ??? ??? ???? ?? www.adhd.or.kr? ?????!
non.Survey.content = ???? ??? ????? ???? ???? ??????
non.Survey.content = ???? ??? ????? ???? ???? ??????.

0 comments on commit 5d8e957

Please sign in to comment.