From c0aedf7beac1d7e84e10a0fc24325d697fbffc0c Mon Sep 17 00:00:00 2001 From: yaaan7 Date: Tue, 16 Jun 2026 03:38:50 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20cardnews=20=ED=94=BC=EB=93=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/CommunityRepository.java | 31 +++++++++++++++++++ .../query/CommunityQueryServiceImpl.java | 29 +++++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/main/java/issueissyu/backend/domain/community/repository/CommunityRepository.java b/src/main/java/issueissyu/backend/domain/community/repository/CommunityRepository.java index 9dd2432..a770cec 100644 --- a/src/main/java/issueissyu/backend/domain/community/repository/CommunityRepository.java +++ b/src/main/java/issueissyu/backend/domain/community/repository/CommunityRepository.java @@ -129,6 +129,37 @@ List findFeedByType( Pageable pageable ); + /** + * CARDNEWS 탭 피드 조회. + * + * 정책/공모전 중 카드뉴스 이미지가 연결된 커뮤니티만 조회한다. + * 지역 조건은 사용하지 않는다. + */ + @Query(""" + select c + from Community c + join fetch c.pin p + join fetch p.user + where c.communityType in :types + and exists ( + select 1 + from CardnewsImageS3 ci + where ci.community = c + ) + and ( + cast(:cursorCreatedAt as LocalDateTime) is null + or c.createdAt < :cursorCreatedAt + or (c.createdAt = :cursorCreatedAt and c.communityId < :cursorId) + ) + order by c.createdAt desc, c.communityId desc + """) + List findCardnewsFeedByTypesWithImages( + @Param("types") Collection types, + @Param("cursorCreatedAt") LocalDateTime cursorCreatedAt, + @Param("cursorId") Long cursorId, + Pageable pageable + ); + /** * ALL 피드 조회. * diff --git a/src/main/java/issueissyu/backend/domain/community/service/query/CommunityQueryServiceImpl.java b/src/main/java/issueissyu/backend/domain/community/service/query/CommunityQueryServiceImpl.java index 03bf9c0..b15fe1c 100644 --- a/src/main/java/issueissyu/backend/domain/community/service/query/CommunityQueryServiceImpl.java +++ b/src/main/java/issueissyu/backend/domain/community/service/query/CommunityQueryServiceImpl.java @@ -82,6 +82,11 @@ public class CommunityQueryServiceImpl implements CommunityQueryService { CommunityType.CARDNEWS ); + private static final List CARDNEWS_FEED_SOURCE_TYPES = List.of( + CommunityType.POLICY, + CommunityType.CONTEST + ); + // HOT 인기 점수 계산용 private static final int HOT_DAYS = 7; // 홈에서 사용 @@ -149,6 +154,26 @@ public CommunityCursorPageResDTO getCommunityFeed( List pageItems = hasNext ? communities.subList(0, size) : communities; List content = toFeedItems(pageItems); + if (tab == CommunityTab.CARDNEWS) { + content = content.stream() + .map(item -> new CommunityFeedItemResDTO( + CommunityType.CARDNEWS, + item.communityId(), + item.pinId(), + item.title(), + item.content(), + item.thumbnailUrl(), + item.writerNickname(), + item.writerProfileUrl(), + item.detailAddress(), + item.viewCount(), + item.likeCount(), + item.discount(), + item.eventStartTime(), + item.eventEndTime() + )) + .toList(); + } String nextCursor = hasNext ? CursorKey.from(pageItems.get(pageItems.size() - 1)).encode() @@ -272,8 +297,8 @@ private List fetchCommunities(CommunityTab tab, Long locationId, Curs limit ); - case CARDNEWS -> communityRepository.findFeedByType( - CommunityType.CARDNEWS, + case CARDNEWS -> communityRepository.findCardnewsFeedByTypesWithImages( + CARDNEWS_FEED_SOURCE_TYPES, cursorKey.createdAt(), cursorKey.communityId(), limit From 4f95d8c301b2b3d8eeafe6205c7b6cdcd0393319 Mon Sep 17 00:00:00 2001 From: yaaan7 Date: Tue, 16 Jun 2026 03:44:39 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20=EC=BF=BC=EB=A6=AC=EB=AC=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/community/repository/CommunityRepository.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/issueissyu/backend/domain/community/repository/CommunityRepository.java b/src/main/java/issueissyu/backend/domain/community/repository/CommunityRepository.java index a770cec..a7cd180 100644 --- a/src/main/java/issueissyu/backend/domain/community/repository/CommunityRepository.java +++ b/src/main/java/issueissyu/backend/domain/community/repository/CommunityRepository.java @@ -141,11 +141,7 @@ List findFeedByType( join fetch c.pin p join fetch p.user where c.communityType in :types - and exists ( - select 1 - from CardnewsImageS3 ci - where ci.community = c - ) + and c.cardnewsImages is not empty and ( cast(:cursorCreatedAt as LocalDateTime) is null or c.createdAt < :cursorCreatedAt