Skip to content

refactor: 마이페이지 배너 매거진 기본값 제거 및 비활성 배너 반환 처리#120

Merged
neibler merged 1 commit intodevelopfrom
feature/118
Feb 11, 2026
Merged

refactor: 마이페이지 배너 매거진 기본값 제거 및 비활성 배너 반환 처리#120
neibler merged 1 commit intodevelopfrom
feature/118

Conversation

@neibler
Copy link
Copy Markdown
Contributor

@neibler neibler commented Feb 11, 2026

🔍️ 작업 내용

  • Closes #

✨ 상세 설명

🛠️ 추후 리팩토링 및 고도화 계획

📸 스크린샷 (선택)

💬 리뷰 요구사항

Summary by CodeRabbit

배너 시스템 업데이트

  • 개선 사항
    • 배너 우선순위 로직이 개선되었습니다.
    • 사용 가능한 배너가 없을 경우 비활성화 상태의 응답으로 변경되었습니다.
    • 매거진 배너 타입이 제거되었습니다.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 11, 2026

Walkthrough

배너 시스템에서 MAGAZINE 타입을 제거하고, 조건을 만족하는 배너가 없을 때 비활성화된 빈 응답을 반환하도록 변경했습니다. API 문서도 이에 맞게 업데이트되었습니다.

Changes

Cohort / File(s) Summary
배너 타입 제거
src/main/java/com/ongil/backend/domain/banner/enums/BannerType.java
MAGAZINE 열거형 상수 제거로 배너 타입 옵션 축소
배너 응답 처리 로직
src/main/java/com/ongil/backend/domain/banner/converter/BannerConverter.java, src/main/java/com/ongil/backend/domain/banner/service/BannerService.java
toEmptyResponse() 메서드 추가 및 createMagazineBanner() 제거로 빈 배너 응답 처리 방식 개선
API 문서 업데이트
src/main/java/com/ongil/backend/domain/banner/controller/BannerController.java
getBanner 엔드포인트 문서 수정: 배너 없을 시 enabled=false 반환 명시

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Possibly related PRs

  • feat: 마이페이지 맞춤형 배너 알림 조회 API 구현 #62: 이 PR에서 도입된 배너 컴포넌트들을 직접 수정 — BannerController 문서, BannerConverter.toEmptyResponse 추가, BannerType의 MAGAZINE 상수 제거, BannerService의 createMagazineBanner 로직 변경이 모두 PR #62의 코드를 대상으로 함
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경 내용의 핵심을 정확하게 반영하고 있습니다: 매거진 배너 기본값 제거 및 비활성 배너 반환 처리라는 주요 변경이 제목에 명확하게 드러나 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/118

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/main/java/com/ongil/backend/domain/banner/service/BannerService.java (1)

51-141: checkInitialReviewBannercheckMonthlyReviewBanner의 중복 로직 추출을 고려해보세요.

두 메서드가 거의 동일한 구조를 공유합니다:

  1. 주문 조회 → 2. OrderItem ID 수집 → 3. 리뷰 작성 여부 조회 → 4. 미작성 항목에 대해 배너 반환

차이점은 주문 조회 조건, ReviewType, BannerType, 그리고 텍스트뿐입니다. 공통 로직을 하나의 private 메서드로 추출하면 DRY 원칙에 부합하고 향후 유지보수가 수월해집니다.

♻️ 리팩토링 예시
+	private BannerResponse findUnreviewedBanner(
+		List<Order> orders, ReviewType reviewType, BannerType bannerType,
+		String title, String buttonText, String targetUrl
+	) {
+		List<Long> allOrderItemIds = orders.stream()
+			.flatMap(order -> order.getOrderItems().stream())
+			.map(OrderItem::getId)
+			.collect(Collectors.toList());
+
+		if (allOrderItemIds.isEmpty()) {
+			return null;
+		}
+
+		Set<Long> reviewedOrderItemIds = reviewRepository
+			.findReviewedOrderItemIds(allOrderItemIds, reviewType)
+			.stream()
+			.collect(Collectors.toSet());
+
+		for (Order order : orders) {
+			for (OrderItem item : order.getOrderItems()) {
+				if (!reviewedOrderItemIds.contains(item.getId())) {
+					return bannerConverter.toResponse(
+						bannerType, title, buttonText, targetUrl, item.getId(), true
+					);
+				}
+			}
+		}
+		return null;
+	}
src/main/java/com/ongil/backend/domain/banner/converter/BannerConverter.java (1)

23-27: toEmptyResponse()에서 반환되는 필드들이 모두 null입니다.

enabled=false인 빈 응답을 반환할 때, type, title, buttonText 등의 다른 필드가 모두 null로 직렬화됩니다. 이는 의도된 설계로 보이지만(메서드명 및 fallback 패턴), JSON 응답을 더 깔끔하게 유지하려면 BannerResponse@JsonInclude(JsonInclude.Include.NON_NULL) 추가를 고려할 수 있습니다. 클라이언트에서는 enabled 필드를 먼저 확인하고 다른 필드를 참조하도록 구현되어야 합니다.

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@neibler neibler merged commit 5ecdd90 into develop Feb 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant