diff --git a/src/main/java/com/koliving/api/room/application/RoomService.java b/src/main/java/com/koliving/api/room/application/RoomService.java index 62f477c5..8bb2dea9 100644 --- a/src/main/java/com/koliving/api/room/application/RoomService.java +++ b/src/main/java/com/koliving/api/room/application/RoomService.java @@ -137,7 +137,7 @@ public void likeRoom(Long roomId, User user) { Room room = getRoom(roomId); final Like like = Like.of(room, user); - likeRepository.findByRoomId(roomId) + likeRepository.findByRoomIdAndUserId(roomId, user.getId()) .ifPresentOrElse( likeRepository::delete, () -> likeRepository.save(like) diff --git a/src/main/java/com/koliving/api/room/infra/LikeRepository.java b/src/main/java/com/koliving/api/room/infra/LikeRepository.java index d8d65405..6f551256 100644 --- a/src/main/java/com/koliving/api/room/infra/LikeRepository.java +++ b/src/main/java/com/koliving/api/room/infra/LikeRepository.java @@ -9,5 +9,5 @@ */ public interface LikeRepository extends JpaRepository { - Optional findByRoomId(Long roomId); + Optional findByRoomIdAndUserId(Long roomId, Long userId); }