Skip to content
Merged
Show file tree
Hide file tree
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 @@ -70,6 +70,7 @@ public record QuestionDetailResponse(
Boolean isPopular,
Integer likeCount,
Boolean isLiked,
Boolean isMine,
LocalDateTime createdAt,
List<CommentResponse> comments
) {
Expand Down Expand Up @@ -144,6 +145,7 @@ public record QuestionSummaryResponse(
Boolean isResolved,
Boolean isPopular,
Boolean isLiked,
Boolean isMine,
Integer likeCount,
Integer commentCount,
// 댓글이 없으면 빈 배열로 내려가며, 프론트는 빈 배열일 때 미리보기 영역을 숨긴다.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public QuestionResDTO.QuestionDetailResponse getQuestionDetail(Long questionId,

private QuestionResDTO.QuestionDetailResponse toDetailResponse(Question question, User loginUser) {
boolean isLiked = questionLikeRepository.existsByQuestionAndUser(question, loginUser);
boolean isMine = question.getUser().getId().equals(loginUser.getId());
boolean isPopular = !question.getIsResolved() && question.getLikeCount() >= POPULAR_LIKE_THRESHOLD;

List<QuestionComment> topComments =
Expand All @@ -89,6 +90,7 @@ private QuestionResDTO.QuestionDetailResponse toDetailResponse(Question question
return new QuestionResDTO.QuestionDetailResponse(
question.getId(), "작성자", question.getContent(), question.getImageUrl(),
question.getIsResolved(), isPopular, question.getLikeCount(), isLiked,
isMine,
question.getCreatedAt(), commentResponses
);
}
Expand Down Expand Up @@ -495,11 +497,13 @@ private QuestionResDTO.QuestionSummaryResponse toQuestionSummaryResponse (
) {
Long questionId = question.getId();
boolean isLiked = questionLikeRepository.existsByQuestionAndUser(question, loginUser);
boolean isMine = question.getUser().getId().equals(loginUser.getId());
return new QuestionResDTO.QuestionSummaryResponse(
questionId, question.getContent(), question.getImageUrl(),
question.getIsResolved(),
!question.getIsResolved() && question.getLikeCount() >= POPULAR_LIKE_THRESHOLD,
isLiked,
isMine,
question.getLikeCount(),
summaryContext.commentCounts().getOrDefault(questionId, 0),
// 목록 화면은 최상위 댓글 중 먼저 달린 3개만 미리보기로 보여준다.
Expand Down
Loading