|
14 | 14 | import java.util.Optional; |
15 | 15 |
|
16 | 16 | public interface LikeRepository extends JpaRepository<PostLike, Long> { |
17 | | - |
18 | 17 | @Query("SELECT l FROM PostLike l " + |
19 | | - "WHERE l.user = :user AND l.post = :post AND l.targetType = 'POST'") |
| 18 | + "WHERE l.user.id = :userId AND l.post.postId = :postId AND l.targetType = 'POST'") |
20 | 19 | Optional<PostLike> findPostLike( |
21 | | - @Param("user") UserEntity user, |
22 | | - @Param("post") Post post |
| 20 | + @Param("userId") Long userId, |
| 21 | + @Param("postId") Long postId |
23 | 22 | ); |
24 | 23 |
|
| 24 | + // 댓글 좋아요 |
25 | 25 | @Query("SELECT l FROM PostLike l " + |
26 | | - "WHERE l.user = :user AND l.comment = :comment AND l.targetType = 'COMMENT'") |
| 26 | + "WHERE l.user.id = :userId AND l.comment.commentId = :commentId AND l.targetType = 'COMMENT'") |
27 | 27 | Optional<PostLike> findCommentLike( |
28 | | - @Param("user") UserEntity user, |
29 | | - @Param("comment") PostComment comment |
| 28 | + @Param("userId") Long userId, |
| 29 | + @Param("commentId") Long commentId |
30 | 30 | ); |
31 | 31 |
|
| 32 | + // 대댓글 좋아요 |
32 | 33 | @Query("SELECT l FROM PostLike l " + |
33 | | - "WHERE l.user = :user AND l.postReply = :reply AND l.targetType = 'REPLY'") |
| 34 | + "WHERE l.user.id = :userId AND l.postReply.replyId = :replyId AND l.targetType = 'REPLY'") |
34 | 35 | Optional<PostLike> findReplyLike( |
35 | | - @Param("user") UserEntity user, |
36 | | - @Param("reply") PostReply reply |
| 36 | + @Param("userId") Long userId, |
| 37 | + @Param("replyId") Long replyId |
37 | 38 | ); |
| 39 | + |
38 | 40 | @Query("SELECT l FROM PostLike l WHERE l.user = :user AND l.targetType = :targetType AND l.post.postId IN :postIds") |
39 | 41 | List<PostLike> findAllByUserAndTargetTypeAndPostIds( |
40 | 42 | @Param("user") UserEntity user, |
|
0 commit comments