Skip to content

Commit

Permalink
fix: 심리테스트 수정-> colors쪽 에러
Browse files Browse the repository at this point in the history
  • Loading branch information
shinheekim committed Aug 5, 2024
1 parent b829c1a commit 12ffc53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public void save(SurveySaveReqDto surveySaveReqDto, Principal principal) {
.build())
.toList();
surveyColorRepository.saveAll(surveyColors);

}

public SurveyResDto findByLoginId(Principal principal) {
Expand Down Expand Up @@ -97,14 +96,15 @@ public void update(SurveySaveReqDto surveySaveReqDto, Principal principal) {
Emotion emotion = emotionRepository.findById(surveySaveReqDto.emotionId())
.orElseThrow(() -> new IllegalArgumentException("해당 감정을 찾을 수 없습니다: " + surveySaveReqDto.emotionId()));
List<Color> colors = colorRepository.findAllById(surveySaveReqDto.colorIds());

List<SurveyColor> surveyColors = colors.stream()
.map(color -> SurveyColor.builder()
.survey(survey)
.color(color)
.build())
.toList();

survey.update(surveySaveReqDto.score(), emotion, surveyColors);

surveyRepository.save(survey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ public class Survey {
public Survey(int score, Emotion emotion, List<SurveyColor> colors, User user) {
this.score = score;
this.emotion = emotion;
this.colors = colors != null ? colors : new ArrayList<>();
this.colors = colors;
this.user = user;
}

public void update(int score, Emotion emotion, List<SurveyColor> colors) {
this.score = score;
this.emotion = emotion;
if (colors != null) {
this.colors.addAll(colors);
}
this.colors.clear();
this.colors.addAll(colors);
}
}

0 comments on commit 12ffc53

Please sign in to comment.