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

[fix] api 정상 플로우 테스트 #39

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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 = ???? ??? ????? ???? ???? ??????.