diff --git a/src/main/java/team3/kummit/repository/EmotionBandArchiveRepository.java b/src/main/java/team3/kummit/repository/EmotionBandArchiveRepository.java index 22319f1..9adac28 100644 --- a/src/main/java/team3/kummit/repository/EmotionBandArchiveRepository.java +++ b/src/main/java/team3/kummit/repository/EmotionBandArchiveRepository.java @@ -5,6 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import team3.kummit.domain.EmotionBandArchive; @@ -12,6 +13,10 @@ public interface EmotionBandArchiveRepository extends JpaRepository findByCreatorIdAndEmotionBandId(Long memberId, Long emotionBandId); boolean existsByCreatorIdAndEmotionBandId(Long memberId, Long emotionBandId); + // 사용자가 보관한 밴드 ID 목록 조회 + @Query("SELECT eba.emotionBand.id FROM EmotionBandArchive eba WHERE eba.creator.id = :memberId") + List findEmotionBandIdListByMemberId(@Param("memberId") Long memberId); + @Query("SELECT eb.id FROM EmotionBand eb where eb.creator.id =:memberId") List findEmotionBandIdListByCreator(Long memberId); } diff --git a/src/main/java/team3/kummit/repository/EmotionBandLikeRepository.java b/src/main/java/team3/kummit/repository/EmotionBandLikeRepository.java index 058de28..01b8d41 100644 --- a/src/main/java/team3/kummit/repository/EmotionBandLikeRepository.java +++ b/src/main/java/team3/kummit/repository/EmotionBandLikeRepository.java @@ -5,6 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import team3.kummit.domain.EmotionBandLike; @@ -12,6 +13,10 @@ public interface EmotionBandLikeRepository extends JpaRepository findByCreatorIdAndEmotionBandId(Long memberId, Long emotionBandId); Long countByEmotionBandId(Long emotionBandId); + // 사용자가 공감한 밴드 ID 목록 조회 + @Query("SELECT ebl.emotionBand.id FROM EmotionBandLike ebl WHERE ebl.creator.id = :memberId") + List findEmotionBandIdListByMemberId(@Param("memberId") Long memberId); + @Query("SELECT eb.id FROM EmotionBand eb where eb.creator.id =:memberId") List findEmotionBandIdListByCreator(Long memberId); } diff --git a/src/main/java/team3/kummit/service/EmotionBandArchiveService.java b/src/main/java/team3/kummit/service/EmotionBandArchiveService.java index f926173..56f3871 100644 --- a/src/main/java/team3/kummit/service/EmotionBandArchiveService.java +++ b/src/main/java/team3/kummit/service/EmotionBandArchiveService.java @@ -87,6 +87,6 @@ public boolean isArchived(Long emotionBandId, Long memberId) { } public List findEmotionBandIdListByCreator(Long memberId){ - return archiveRepository.findEmotionBandIdListByCreator(memberId); + return archiveRepository.findEmotionBandIdListByMemberId(memberId); } } diff --git a/src/main/java/team3/kummit/service/EmotionBandLikeService.java b/src/main/java/team3/kummit/service/EmotionBandLikeService.java index 3b70c73..1f64a05 100644 --- a/src/main/java/team3/kummit/service/EmotionBandLikeService.java +++ b/src/main/java/team3/kummit/service/EmotionBandLikeService.java @@ -96,6 +96,6 @@ public boolean isLiked(Long emotionBandId, Long memberId) { } public List findEmotionBandListByMemberId(Long memberId) { - return bandRepository.findEmotionBandIdListByCreator(memberId); + return likeRepository.findEmotionBandIdListByMemberId(memberId); } }