diff --git a/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/mybook/service/MyBookService.java b/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/mybook/service/MyBookService.java index 0dc4001..c51a24c 100644 --- a/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/mybook/service/MyBookService.java +++ b/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/mybook/service/MyBookService.java @@ -83,7 +83,10 @@ public MyBookDetailDto findByIdForDetail(long id) { MyBook myBook = findById(id); PostKeyword postKeyword = myBook.getProduct().getPostKeyword(); - List postHashTags = postHashTagService.findByPostKeyword(postKeyword); + Member author = myBook.getProduct().getAuthor(); + + // 해당 작가, 키워드와 관련된 글만 조회 + List postHashTags = postHashTagService.findByPostKeywordAndMember(postKeyword, author); List posts = postHashTags.stream() .map(postHashTag -> postHashTag.getPost()) diff --git a/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/postHashTag/repository/PostHashTagRepository.java b/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/postHashTag/repository/PostHashTagRepository.java index b9622aa..2cc63ae 100644 --- a/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/postHashTag/repository/PostHashTagRepository.java +++ b/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/postHashTag/repository/PostHashTagRepository.java @@ -1,5 +1,6 @@ package com.example.mutbooks.app.postHashTag.repository; +import com.example.mutbooks.app.member.entity.Member; import com.example.mutbooks.app.postHashTag.entity.PostHashTag; import com.example.mutbooks.app.postKeyword.entity.PostKeyword; import org.springframework.data.jpa.repository.JpaRepository; @@ -12,5 +13,5 @@ public interface PostHashTagRepository extends JpaRepository List findByPostId(Long postId); - List findByPostKeyword(PostKeyword postKeyword); + List findByPostKeywordAndMember(PostKeyword postKeyword, Member member); } diff --git a/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/postHashTag/service/PostHashTagService.java b/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/postHashTag/service/PostHashTagService.java index cca6459..978eefd 100644 --- a/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/postHashTag/service/PostHashTagService.java +++ b/4Week_Mission/mutbooks/src/main/java/com/example/mutbooks/app/postHashTag/service/PostHashTagService.java @@ -1,10 +1,11 @@ package com.example.mutbooks.app.postHashTag.service; +import com.example.mutbooks.app.member.entity.Member; +import com.example.mutbooks.app.post.entity.Post; import com.example.mutbooks.app.postHashTag.entity.PostHashTag; import com.example.mutbooks.app.postHashTag.repository.PostHashTagRepository; import com.example.mutbooks.app.postKeyword.entity.PostKeyword; import com.example.mutbooks.app.postKeyword.service.PostKeywordService; -import com.example.mutbooks.app.post.entity.Post; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -78,7 +79,7 @@ public List findByPostId(long postId) { return postHashTagRepository.findByPostId(postId); } - public List findByPostKeyword(PostKeyword postKeyword) { - return postHashTagRepository.findByPostKeyword(postKeyword); + public List findByPostKeywordAndMember(PostKeyword postKeyword, Member member) { + return postHashTagRepository.findByPostKeywordAndMember(postKeyword, member); } }