diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java b/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java index e466d215..42691e62 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java @@ -369,16 +369,20 @@ else if (childList.get(3) != YES || parentList.get(3) != YES) { public GetMainViewResponseDto getMainInfo(Long userId) { // updateUserFirstEntry(userId); - - Parentchild parentchild = getParentchild(userId); - + User user = getUserById(userId); + Parentchild parentchild = user.getParentChild(); List qnaList = getQnAListByParentchild(parentchild); QnA currentQnA = qnaList.get(parentchild.getCount()-1); log.info("getCount(): {}", parentchild.getCount()); - if (parentchild.getCount() == 7 && (currentQnA.isParentAnswer() && currentQnA.isChildAnswer())) { + if (parentchild.getCount() == 7 && (currentQnA.isParentAnswer() && currentQnA.isChildAnswer()) && !user.isEndingDone()) { return GetMainViewResponseDto.of(currentQnA, -1); // 유효하지 않은 -1로 반환 시 엔딩이벤트 + } else if (parentchild.getCount() == 8) { + QnA lastQnA = qnaList.get(6); + if ((lastQnA.isParentAnswer() && lastQnA.isChildAnswer()) && !user.isEndingDone()) { + return GetMainViewResponseDto.of(currentQnA, -1); + } } return GetMainViewResponseDto.of(currentQnA, parentchild.getCount()); @@ -396,7 +400,9 @@ public FirstEntryResponseDto updateUserFirstEntry(Long userId) { @Transactional public void restartQna(Long userId) { - Parentchild parentchild = getParentchild(userId); + User user = getUserById(userId); + user.updateIsEndingDone(); + Parentchild parentchild = user.getParentChild(); if (parentchild.getCount() == 8) { // 상대측이 이미 답변 이어가기를 호출했다면 실행할 필요 X diff --git a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java index 36334cf0..21a45fc4 100644 --- a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java +++ b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java @@ -108,6 +108,8 @@ public void updateFcmToken(String fcmToken) { private boolean isFirstEntry = Boolean.TRUE; + private boolean isEndingDone = Boolean.FALSE; + // 로그인 새롭게 할 때마다 해당 필드들 업데이트 public void updateSocialInfo(String socialNickname, String socialProfileImage, String socialAccessToken/*, String socialRefreshToken*/) { this.socialNickname = socialNickname; @@ -126,6 +128,8 @@ public void updateIsFirstEntry() { this.isFirstEntry = false; } + public void updateIsEndingDone() { this.isEndingDone = true; } + public void deleteSocialInfo() { this.socialPlatform = SocialPlatform.WITHDRAW; this.socialNickname = null;