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..a7cd180 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,33 @@ 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 c.cardnewsImages is not empty + 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 diff --git a/src/main/java/issueissyu/backend/global/config/SwaggerConfig.java b/src/main/java/issueissyu/backend/global/config/SwaggerConfig.java index 1e592e1..16a209e 100644 --- a/src/main/java/issueissyu/backend/global/config/SwaggerConfig.java +++ b/src/main/java/issueissyu/backend/global/config/SwaggerConfig.java @@ -36,7 +36,7 @@ public OpenAPI openAPI() { .description("IssueIssyu Local Server"); Server httpServer = new Server() - .url("http://issueissyu-backend-prod-env.eba-x2fpm3aq.ap-northeast-2.elasticbeanstalk.com") + .url("https://spring.issueissyu.cloud") .description("IssueIssyu Prod Server");