Skip to content

Commit

Permalink
[FIX] DTO 생성자 오류 수정 #148
Browse files Browse the repository at this point in the history
  • Loading branch information
ddongseop committed Apr 30, 2024
1 parent 2713361 commit 6b72b07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,18 @@ public static MyUserInfoResponseDto of(User myUser, Parentchild parentchild) {
}

// 상대방이 탈퇴했을 경우
public static MyUserInfoResponseDto of(User myUser, Parentchild parentchild, boolean isOpponentExit) {
public static MyUserInfoResponseDto of(User myUser, User opponentUser, Parentchild parentchild, QnA qnA, long date, int qnaCnt, boolean isOpponentExit) {

return MyUserInfoResponseDto.builder()
.myUsername(myUser.getUsername())
.myUserType(getUserType(parentchild.getRelation(), myUser.isMeChild()))
.opponentUserType(getUserType(parentchild.getRelation(), !myUser.isMeChild()))
.opponentUsername(opponentUser.getUsername())
.opponentUserType(getUserType(parentchild.getRelation(), opponentUser.isMeChild()))
.parentchildRelation(parentchild.getRelation().getValue())
.isMeChild(myUser.isMeChild())
.section(QuestionSection.YOUNG.getValue())
.matchedDate(0L)
.qnaCnt(0)
.inviteCode(parentchild.getInviteCode())
.installUrl("http://umbba.site/")
.section(qnA.getQuestion().getSection().getValue())
.matchedDate(date) // 일수와 문답 수는 다를 수 있음
.qnaCnt(qnaCnt)
.isOpponentExit(isOpponentExit)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,6 @@ public MyUserInfoResponseDto getUserInfo(final Long userId) {
}

User opponentUser = getOpponentByParentchild(parentchild, userId);
// 상대 유저가 탈퇴했을 경우
if (opponentUser.getSocialPlatform().equals(WITHDRAW)) {
return MyUserInfoResponseDto.of(myUser, parentchild, true);
}

QnA todayQnA = getTodayQnAByParentchild(parentchild);

Expand All @@ -296,6 +292,11 @@ public MyUserInfoResponseDto getUserInfo(final Long userId) {
LocalDateTime firstQnADate = parentchild.getQnaList().get(0).getCreatedAt();
long qnaDate = ChronoUnit.DAYS.between(firstQnADate, LocalDateTime.now());

// 상대 유저가 탈퇴했을 경우
if (opponentUser.getSocialPlatform().equals(WITHDRAW)) {
return MyUserInfoResponseDto.of(myUser, opponentUser, parentchild, todayQnA, qnaDate, qnaCnt, true);
}

return MyUserInfoResponseDto.of(myUser, opponentUser, parentchild, todayQnA, qnaDate, qnaCnt);
}

Expand Down

0 comments on commit 6b72b07

Please sign in to comment.