diff --git a/.gradle/8.8/executionHistory/executionHistory.bin b/.gradle/8.8/executionHistory/executionHistory.bin index 07118a8..e2f93b6 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.bin and b/.gradle/8.8/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.8/executionHistory/executionHistory.lock b/.gradle/8.8/executionHistory/executionHistory.lock index 13168bb..21f7540 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.lock and b/.gradle/8.8/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.8/fileHashes/fileHashes.bin b/.gradle/8.8/fileHashes/fileHashes.bin index 8bdc623..586f5e9 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.bin and b/.gradle/8.8/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.8/fileHashes/fileHashes.lock b/.gradle/8.8/fileHashes/fileHashes.lock index 27705ad..51e0e99 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.lock and b/.gradle/8.8/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.8/fileHashes/resourceHashesCache.bin b/.gradle/8.8/fileHashes/resourceHashesCache.bin index aea5b3f..46fb6aa 100644 Binary files a/.gradle/8.8/fileHashes/resourceHashesCache.bin and b/.gradle/8.8/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 8c95f68..7294e2e 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/Article$ArticleBuilder.class.uniqueId7 b/build/tmp/compileJava/compileTransaction/stash-dir/Article$ArticleBuilder.class.uniqueId7 deleted file mode 100644 index 94e021b..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/Article$ArticleBuilder.class.uniqueId7 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/Article.class.uniqueId12 b/build/tmp/compileJava/compileTransaction/stash-dir/Article.class.uniqueId12 deleted file mode 100644 index 8f16256..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/Article.class.uniqueId12 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ArticleDataLoader.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/ArticleDataLoader.class.uniqueId2 similarity index 100% rename from build/tmp/compileJava/compileTransaction/stash-dir/ArticleDataLoader.class.uniqueId1 rename to build/tmp/compileJava/compileTransaction/stash-dir/ArticleDataLoader.class.uniqueId2 diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ArticleRepository.class.uniqueId10 b/build/tmp/compileJava/compileTransaction/stash-dir/ArticleRepository.class.uniqueId3 similarity index 100% rename from build/tmp/compileJava/compileTransaction/stash-dir/ArticleRepository.class.uniqueId10 rename to build/tmp/compileJava/compileTransaction/stash-dir/ArticleRepository.class.uniqueId3 diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ArticleServiceImpl.class.uniqueId11 b/build/tmp/compileJava/compileTransaction/stash-dir/ArticleServiceImpl.class.uniqueId4 similarity index 100% rename from build/tmp/compileJava/compileTransaction/stash-dir/ArticleServiceImpl.class.uniqueId11 rename to build/tmp/compileJava/compileTransaction/stash-dir/ArticleServiceImpl.class.uniqueId4 diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ArticleTag$ArticleTagBuilder.class.uniqueId4 b/build/tmp/compileJava/compileTransaction/stash-dir/ArticleTag$ArticleTagBuilder.class.uniqueId4 deleted file mode 100644 index 3c79125..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/ArticleTag$ArticleTagBuilder.class.uniqueId4 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ArticleTag.class.uniqueId13 b/build/tmp/compileJava/compileTransaction/stash-dir/ArticleTag.class.uniqueId13 deleted file mode 100644 index 9b4c6c0..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/ArticleTag.class.uniqueId13 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ArticleTagRepository.class.uniqueId8 b/build/tmp/compileJava/compileTransaction/stash-dir/ArticleTagRepository.class.uniqueId1 similarity index 80% rename from build/tmp/compileJava/compileTransaction/stash-dir/ArticleTagRepository.class.uniqueId8 rename to build/tmp/compileJava/compileTransaction/stash-dir/ArticleTagRepository.class.uniqueId1 index 2d6591d..59a7c64 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/ArticleTagRepository.class.uniqueId8 and b/build/tmp/compileJava/compileTransaction/stash-dir/ArticleTagRepository.class.uniqueId1 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/Scrap$ScrapBuilder.class.uniqueId3 b/build/tmp/compileJava/compileTransaction/stash-dir/Scrap$ScrapBuilder.class.uniqueId3 deleted file mode 100644 index d83ef36..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/Scrap$ScrapBuilder.class.uniqueId3 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/Scrap.class.uniqueId2 b/build/tmp/compileJava/compileTransaction/stash-dir/Scrap.class.uniqueId2 deleted file mode 100644 index 8669f4e..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/Scrap.class.uniqueId2 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ScrapController.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/ScrapController.class.uniqueId0 index a83099c..9849f4a 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/ScrapController.class.uniqueId0 and b/build/tmp/compileJava/compileTransaction/stash-dir/ScrapController.class.uniqueId0 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ScrapRepository.class.uniqueId9 b/build/tmp/compileJava/compileTransaction/stash-dir/ScrapRepository.class.uniqueId9 deleted file mode 100644 index 03c07fe..0000000 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/ScrapRepository.class.uniqueId9 and /dev/null differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/ScrapService.class.uniqueId6 b/build/tmp/compileJava/compileTransaction/stash-dir/ScrapService.class.uniqueId6 index 9211ebe..d0dc1fa 100644 Binary files a/build/tmp/compileJava/compileTransaction/stash-dir/ScrapService.class.uniqueId6 and b/build/tmp/compileJava/compileTransaction/stash-dir/ScrapService.class.uniqueId6 differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index 1c708f1..4332d66 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/src/main/java/com/winner_cat/domain/article/repository/ArticleRepository.java b/src/main/java/com/winner_cat/domain/article/repository/ArticleRepository.java index 4cbfe39..151f2d0 100644 --- a/src/main/java/com/winner_cat/domain/article/repository/ArticleRepository.java +++ b/src/main/java/com/winner_cat/domain/article/repository/ArticleRepository.java @@ -27,4 +27,7 @@ public interface ArticleRepository extends JpaRepository { // 오늘 작성된 게시글 찾기 @Query("SELECT a FROM Article a WHERE a.createdAt >= :startTime AND a.createdAt <= :endTime") List
findAllByCreatedAtBetween(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime); + + @Query("SELECT a FROM Article a JOIN a.tags at JOIN at.tag t JOIN a.scrapList s WHERE s.member.id = :memberId AND t.tagName = :tagName ORDER BY a.createdAt DESC") + Page
findScrappedArticlesByTag(@Param("memberId") Long memberId, @Param("tagName") String tagName, Pageable pageable); } diff --git a/src/main/java/com/winner_cat/domain/article/repository/ArticleTagRepository.java b/src/main/java/com/winner_cat/domain/article/repository/ArticleTagRepository.java index 9a2e950..f2be06c 100644 --- a/src/main/java/com/winner_cat/domain/article/repository/ArticleTagRepository.java +++ b/src/main/java/com/winner_cat/domain/article/repository/ArticleTagRepository.java @@ -26,8 +26,8 @@ public interface ArticleTagRepository extends JpaRepository { // 태그 이름으로 묶어서 내림차순 추출 @Query("SELECT at.tag.tagName, COUNT(at) FROM ArticleTag at WHERE at.article IN :articles GROUP BY at.tag.tagName ORDER BY COUNT(at) DESC") List findTopTagsByArticles(@Param("articles") List
articles); - - // 회원이 스크랩한 게시글 중 특정 태그에 해당하는 게시글 페이징 조회 - @Query("SELECT at FROM ArticleTag at JOIN at.article a JOIN a.scrapList sc WHERE sc.member = :member and at.tag = :tag ORDER BY a.createdAt DESC") - Page findScrapArticleTagPageByTag(Member member, Tag tag, Pageable pageable); +// +// // 회원이 스크랩한 게시글 중 특정 태그에 해당하는 게시글 페이징 조회 +// @Query("SELECT at FROM ArticleTag at JOIN at.article a JOIN a.scrapList sc WHERE sc.member = :member and at.tag = :tag ORDER BY a.createdAt DESC") +// Page findScrapArticleTagPageByTag(Member member, Tag tag, Pageable pageable); } diff --git a/src/main/java/com/winner_cat/domain/scrap/controller/ScrapController.java b/src/main/java/com/winner_cat/domain/scrap/controller/ScrapController.java index 34b68d8..e1a9ea0 100644 --- a/src/main/java/com/winner_cat/domain/scrap/controller/ScrapController.java +++ b/src/main/java/com/winner_cat/domain/scrap/controller/ScrapController.java @@ -35,6 +35,17 @@ public ResponseEntity getAllMyScrapArticles( return scrapService.getAllMyScrapArticles(userDetails.getEmail(), pageable); } + /** + * 태그로 내가 스크랩한 게시글 조회(미리보기) + */ + @GetMapping("/mine/tag") + public ResponseEntity getAllMyScrapArticlesByTag( + @AuthenticationPrincipal CustomUserDetails userDetails, + @RequestParam String tagName, + Pageable pageable) { + return scrapService.getAllMyScrapArticlesByTag(userDetails.getEmail(), tagName, pageable); + } + /** * 스크랩 취소 */ diff --git a/src/main/java/com/winner_cat/domain/scrap/service/ScrapService.java b/src/main/java/com/winner_cat/domain/scrap/service/ScrapService.java index 0a62ded..2482ebb 100644 --- a/src/main/java/com/winner_cat/domain/scrap/service/ScrapService.java +++ b/src/main/java/com/winner_cat/domain/scrap/service/ScrapService.java @@ -34,8 +34,6 @@ public class ScrapService { private final ScrapRepository scrapRepository; private final MemberRepository memberRepository; private final ArticleRepository articleRepository; - private final TagRepository tagRepository; - private final ArticleTagRepository articleTagRepository; public ResponseEntity scrapArticle(String email, Long articleId) { // 1. 회원 조회 @@ -105,15 +103,13 @@ public ResponseEntity getAllMyScrapArticlesByTag(String email, String tagName // 1. 사용자 정보 얻어오기 Member member = memberRepository.findMemberByEmail(email) .orElseThrow(() -> new GeneralException(ErrorStatus.MEMBER_NOT_FOUND)); - // 2. 태그 정보 얻어오기 - Tag tag = tagRepository.findByTagName(tagName) - .orElseThrow(() -> new GeneralException(ErrorStatus.TAG_NOT_FOUND)); - // 3. 해당 회원이 스크랩한 태그 정보 조회 - Page scrapArticleTagPageByTag = articleTagRepository.findScrapArticleTagPageByTag(member, tag, pageable); - int totalPages = scrapArticleTagPageByTag.getTotalPages(); + + // 2. 해당 회원이 스크랩한 태그 정보 조회 + Page
scrappedArticlesByTag = articleRepository.findScrappedArticlesByTag(member.getId(), tagName, pageable); + int totalPages = scrappedArticlesByTag.getTotalPages(); + List articlePreviewList = new ArrayList<>(); - for (ArticleTag articleTag : scrapArticleTagPageByTag.getContent()) { - Article article = articleTag.getArticle(); + for (Article article : scrappedArticlesByTag.getContent()) { // 관련 태그들 얻어오기 List tagResponseDtoList = article.getTags().stream() .map(at -> TagResponseDto.builder()