Merged
Conversation
kwonhee1
commented
May 31, 2025
| 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") |
Member
Author
There was a problem hiding this comment.
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) |
Member
Author
There was a problem hiding this comment.
예정과 같은 이유
user Id값이 null인 경우 c.user.id <> :userId에서 무조건 false를 반환하여 수정
| .likeCount(comment.getLikeCount()) | ||
| .createTime(comment.getCreateTime()) | ||
| .isDeleted(comment.getUser() == null) | ||
| .build(); |
| AND question.category.name = :category | ||
| group by question | ||
| ORDER BY FUNCTION('date', question.createTime) DESC, count(c) desc | ||
| ORDER BY question.createTime desc |
| @Modifying | ||
| @Query("update Comment c set c.likeCount = c.likeCount - 1 where c.id in :commentIds") | ||
| void updateLikeCount(@Param("commentIds") List<Long> commentIds); | ||
|
|
Member
Author
There was a problem hiding this comment.
user 삭제때 해당 user가 like한 값 삭제됨
해당 댓글의 like count 값 변경
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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값또한 같이 가져옴