Skip to content

[FEAT] 카드뉴스 피드 조회#350

Merged
yaaan7 merged 2 commits into
developfrom
feat/349-cardnews-feed
Jun 15, 2026
Merged

[FEAT] 카드뉴스 피드 조회#350
yaaan7 merged 2 commits into
developfrom
feat/349-cardnews-feed

Conversation

@yaaan7

@yaaan7 yaaan7 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

🔗 Related Issue

✨ 작업 개요

작업 내용을 간략하게 작성해주세요.
피드 목록 조회 시 카드뉴스 탭 조회 기능을 구현하였습니다.
카드뉴스의 첫번째 페이지를 썸네일로 반환합니다.

체크리스트

  • Reviewers, Assignees, Labels를 모두 등록했나요?
  • .gitignore 설정을 하였나요?
  • PR 머지 전 반드시 CI가 정상적으로 작동하는지 확인해주세요!

📷 이미지 첨부 (선택)

  • 작업 결과를 확인할 수 있는 이미지나 GIF를 첨부해주세요.
  • UI 변경, API 응답 샘플, 테스트 결과 등이 포함되면 좋아요!
image

🧐 집중 리뷰 요청

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요.

@yaaan7 yaaan7 self-assigned this Jun 15, 2026
@yaaan7 yaaan7 added the ⭐ feat 새로운 기능 label Jun 15, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new query and logic to fetch and map CARDNEWS feeds from specific source types (POLICY and CONTEST) that have associated card news images. Feedback focuses on improving the JPQL query by using IS NOT EMPTY instead of an exists subquery, and refactoring the DTO mapping logic in CommunityQueryServiceImpl to avoid redundant stream mapping and improve maintainability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +144 to +148
and exists (
select 1
from CardnewsImageS3 ci
where ci.community = c
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

JPQL에서는 연관 관계 컬렉션이 비어있지 않은지 확인할 때 IS NOT EMPTY 키워드를 사용할 수 있습니다.

현재 작성된 exists 서브쿼리 대신 c.cardnewsImages is not empty를 사용하면 쿼리가 훨씬 간결해지고 가독성이 향상됩니다.

Suggested change
and exists (
select 1
from CardnewsImageS3 ci
where ci.community = c
)
and c.cardnewsImages is not empty

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +157 to +176
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();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

현재 tab == CommunityTab.CARDNEWS일 때, 이미 생성된 CommunityFeedItemResDTO 리스트를 다시 스트림으로 순회하며 모든 필드를 복사하고 kindCARDNEWS로 변경하고 있습니다. 이 방식은 다음과 같은 문제가 있습니다:

  1. 유지보수성 저하: CommunityFeedItemResDTO에 새로운 필드가 추가되거나 기존 필드가 변경될 때, 14개의 인자를 가진 생성자를 호출하는 이 코드도 함께 수정해야 하므로 변경에 취약합니다.
  2. 불필요한 객체 생성: 리스트를 두 번 매핑하면서 불필요한 DTO 객체들이 추가로 생성됩니다.

개선 제안:
toFeedItems 메서드가 CommunityType 오버라이드를 지원하도록 오버로딩하여, 처음부터 원하는 타입으로 DTO를 생성하도록 리팩토링하는 것을 권장합니다.

이를 위해 CommunityQueryServiceImpl 클래스 내부의 toFeedItemstoFeedItem 메서드를 다음과 같이 수정해 주세요:

private List<CommunityFeedItemResDTO> toFeedItems(List<Community> communities) {
    return toFeedItems(communities, null);
}

private List<CommunityFeedItemResDTO> toFeedItems(List<Community> communities, CommunityType typeOverride) {
    FeedItemContext context = buildFeedItemContext(communities);
    return communities.stream()
            .map(community -> toFeedItem(community, context, typeOverride))
            .toList();
}

private CommunityFeedItemResDTO toFeedItem(Community community, FeedItemContext context, CommunityType typeOverride) {
    Pin pin = community.getPin();
    CommunityType type = typeOverride != null ? typeOverride : community.getCommunityType();
    Long pinId = pin.getPinId();
    EventPin eventPin = context.eventPinByPinId().get(pinId);

    return new CommunityFeedItemResDTO(
            type,
            community.getCommunityId(),
            pinId,
            pin.getPinTitle(),
            pin.getPinContent(),
            resolveFeedThumbnailUrl(community, context).orElse(null),
            resolveFeedWriterNickname(community.getCommunityType(), pin, eventPin, context),
            resolveFeedWriterProfileUrl(community.getCommunityType(), pin, eventPin, context),
            context.addressByPinId().get(pinId),
            pin.getViewCount(),
            pin.getLikeCount(),
            eventPin != null ? eventPin.getDiscount() : null,
            eventPin != null ? eventPin.getEventStartTime() : null,
            eventPin != null ? eventPin.getEventEndTime() : null
    );
}
        if (tab == CommunityTab.CARDNEWS) {
            content = toFeedItems(pageItems, CommunityType.CARDNEWS);
        }

@yaaan7 yaaan7 merged commit cb0483d into develop Jun 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⭐ feat 새로운 기능

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 커뮤니티 카드뉴스 피드 조회 기능 구현

1 participant