Skip to content

Refactor/back#114

Merged
kwonhee1 merged 6 commits intodevelopfrom
refactor/back
May 31, 2025
Merged

Refactor/back#114
kwonhee1 merged 6 commits intodevelopfrom
refactor/back

Conversation

@kwonhee1
Copy link
Copy Markdown
Member

update : user delete : update comment like count -1 : 6282e8e
user delete 될때 user 가 좋아요한 comment의 like count -= 1;
refactor : question list order by createTime : 3dea18f
회의 변경 내용 : question list에서 order by 기준 시간순
feat : comment add isDeleted column : 796cdcb
'이미 떠나간 여운입니다' 댓글을 구분하기 위한 isDeleted column추가
모든 댓글 정보를 가져올때 해당 댓글의 작성자 user값또한 같이 가져옴

Optional<Comment> getCommentByUserId(@Param("userId") Long userId, @Param("questionId")Long questionId);

@Query("SELECT c FROM Comment c LEFT JOIN FETCH c.user LEFT JOIN FETCH c.question WHERE c.id = :id")
@Query("SELECT c FROM Comment c LEFT JOIN FETCH c.question WHERE c.id = :id")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment 에서 user fetch type 변경으로 fetch join 삭제

FROM Comment c
LEFT JOIN c.likes l
WHERE c.question.id = :questionId AND c.user.id <> :userId
WHERE c.question.id = :questionId AND (c.user.id <> :userId or c.user.id is null)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예정과 같은 이유
user Id값이 null인 경우 c.user.id <> :userId에서 무조건 false를 반환하여 수정

.likeCount(comment.getLikeCount())
.createTime(comment.getCreateTime())
.isDeleted(comment.getUser() == null)
.build();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDeleted column 추가

AND question.category.name = :category
group by question
ORDER BY FUNCTION('date', question.createTime) DESC, count(c) desc
ORDER BY question.createTime desc
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정렬 순서 무조건 시간순으로 변경

@Modifying
@Query("update Comment c set c.likeCount = c.likeCount - 1 where c.id in :commentIds")
void updateLikeCount(@Param("commentIds") List<Long> commentIds);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user 삭제때 해당 user가 like한 값 삭제됨
해당 댓글의 like count 값 변경

@kwonhee1 kwonhee1 merged commit 7a768de into develop May 31, 2025
2 checks passed
@wheon06 wheon06 deleted the refactor/back branch June 16, 2025 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant