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

chore: 임시저장 예외케이스 수정 #136

Merged
merged 2 commits into from
Aug 9, 2024
Merged
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 @@ -47,12 +47,9 @@ public class AnswerService {

@Transactional
public void create(AnswerListCreateRequest request, Long spaceId, Long retrospectId, Long memberId) {
// 스페이스 팀원인지 검증
Optional<MemberSpaceRelation> team = memberSpaceRelationRepository.findBySpaceIdAndMemberId(
spaceId, memberId);
if (team.isEmpty()) {
throw new MemberSpaceRelationException(NOT_FOUND_MEMBER_SPACE_RELATION);
}
// 해당 스페이스 팀원인지 검증
Team team = new Team(memberSpaceRelationRepository.findAllBySpaceId(spaceId));
team.validateTeamMembership(memberId);

// 회고 존재 검증
Retrospect retrospect = retrospectRepository.findByIdOrThrow(retrospectId);
Expand All @@ -62,14 +59,16 @@ public void create(AnswerListCreateRequest request, Long spaceId, Long retrospec
List<Long> questionIds = request.requests().stream()
.map(AnswerCreateRequest::questionId)
.toList();
Questions questions = new Questions(questionRepository.findAllByIdIn(questionIds));
Questions questions = new Questions(questionRepository.findAllByRetrospectIdOrderByQuestionOrder(retrospectId));
questions.validateQuestionSize(questionIds.size());

// 회고 질문 유효성 검사 - 이미 응답을 하지 않았는지
Answers answers = new Answers(
if (!request.isTemporarySave()) {
Answers answers = new Answers(
answerRepository.findByRetrospectIdAndMemberIdAndAnswerStatusAndQuestionIdIn(retrospectId, memberId,
AnswerStatus.DONE, questionIds));
answers.validateNoAnswer();
AnswerStatus.DONE, questionIds));
answers.validateNoAnswer();
}

// 기존 임시답변 제거
answerRepository.deleteAllByRetrospectIdAndMemberIdAndAnswerStatus(retrospectId, memberId,
Expand Down