diff --git a/src/main/java/sopt/org/umbbaServer/domain/parentchild/service/ParentchildService.java b/src/main/java/sopt/org/umbbaServer/domain/parentchild/service/ParentchildService.java index b6a9e1d0..65140a58 100644 --- a/src/main/java/sopt/org/umbbaServer/domain/parentchild/service/ParentchildService.java +++ b/src/main/java/sopt/org/umbbaServer/domain/parentchild/service/ParentchildService.java @@ -44,10 +44,6 @@ public class ParentchildService { public OnboardingInviteResponseDto onboardInvite(Long userId, OnboardingInviteRequestDto request) { User user = getUserById(userId); - if (user.getParentChild() != null) { - throw new CustomException(ErrorType.ALREADY_EXISTS_PARENT_CHILD_USER); - } - user.updateOnboardingInfo( request.getUserInfo().getName(), request.getUserInfo().getGender(), @@ -93,45 +89,46 @@ public OnboardingInviteResponseDto onboardInvite(Long userId, OnboardingInviteRe @Transactional public OnboardingReceiveResponseDto onboardReceive(Long userId, OnboardingReceiveRequestDto request) throws InterruptedException { - if (getUserById(userId).getParentChild() != null) { - User user = getUserById(userId); - user.updateOnboardingInfo( - request.getUserInfo().getName(), - request.getUserInfo().getGender(), - request.getUserInfo().getBornYear() - ); + if (getUserById(userId).getParentChild() == null) { + throw new CustomException(ErrorType.RECEIVE_AFTER_MATCH); + } - Parentchild parentchild = user.getParentChild(); + User user = getUserById(userId); + user.updateOnboardingInfo( + request.getUserInfo().getName(), + request.getUserInfo().getGender(), + request.getUserInfo().getBornYear() + ); + + Parentchild parentchild = user.getParentChild(); // parentchild.updateInfo(); TODO 온보딩 송수신 측의 관계 정보가 불일치한 경우에 대한 처리 - List parentChildUsers = getParentChildUsers(parentchild); + List parentChildUsers = getParentChildUsers(parentchild); - // String을 Enum으로 변경 - List onboardingAnswerList = request.getOnboardingAnswerList().stream() - .map(OnboardingAnswer::of) - .collect(Collectors.toList()); + // String을 Enum으로 변경 + List onboardingAnswerList = request.getOnboardingAnswerList().stream() + .map(OnboardingAnswer::of) + .collect(Collectors.toList()); - if (onboardingAnswerList.size() != 5) { - throw new CustomException(ErrorType.INVALID_ONBOARDING_ANSWER_SIZE); - } + if (onboardingAnswerList.size() != 5) { + throw new CustomException(ErrorType.INVALID_ONBOARDING_ANSWER_SIZE); + } - if (getUserById(userId).isMeChild()) { - parentchild.changeChildOnboardingAnswerList(onboardingAnswerList); - } else { - parentchild.changeParentOnboardingAnswerList(onboardingAnswerList); - } + if (getUserById(userId).isMeChild()) { + parentchild.changeChildOnboardingAnswerList(onboardingAnswerList); + } else { + parentchild.changeParentOnboardingAnswerList(onboardingAnswerList); + } - /*if (!ParentchildRelation.validate(parentChildUsers, parentchild.getRelation())) { - throw new CustomException(ErrorType.INVALID_PARENT_CHILD_RELATION); - }*/ - ScheduleConfig.resetScheduler(); - fcmScheduler.pushTodayQna(); + /*if (!ParentchildRelation.validate(parentChildUsers, parentchild.getRelation())) { + throw new CustomException(ErrorType.INVALID_PARENT_CHILD_RELATION); + }*/ + ScheduleConfig.resetScheduler(); + fcmScheduler.pushTodayQna(); - return OnboardingReceiveResponseDto.of(parentchild, user, parentChildUsers); - } + return OnboardingReceiveResponseDto.of(parentchild, user, parentChildUsers); - throw new CustomException(ErrorType.RECEIVE_AFTER_MATCH); }