Skip to content

Commit

Permalink
update :: exists 쿼리로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ta2ye0n committed Sep 23, 2024
1 parent 9ba1cd2 commit 02db7ac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ interface MusicLikeRepository : JpaRepository<MusicLike, Long> {
@Lock(LockModeType.PESSIMISTIC_WRITE)
@Query("select l from MusicLike l where l.memberId = :memberId and l.musicId = :musicId")
fun findByMemberIdAndMusicId(@Param("memberId") memberId: Long, @Param("musicId") musicId: Long): MusicLike?

fun existsByMusicIdAndMemberId(musicId: Long, memberId: Long): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FindMusicRankServiceImpl(
private fun checkLike(music: Music): Boolean {
val member = userUtil.fetchCurrentUser()

return musicLikeRepository.findByMemberIdAndMusicId(member.id, music.id) != null
return musicLikeRepository.existsByMusicIdAndMemberId(music.id, member.id)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class FindMusicsServiceImpl(
private fun checkLike(music: Music): Boolean {
val member = userUtil.fetchCurrentUser()

return musicLikeRepository.findByMemberIdAndMusicId(member.id, music.id) != null
return musicLikeRepository.existsByMusicIdAndMemberId(music.id, member.id)
}

}

0 comments on commit 02db7ac

Please sign in to comment.