Refactor/#176 플랫폼 연동 현황 조회 개선 & 재연동 API 추가#177
Conversation
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughDISCONNECTED 플랫폼 계정이 연동 현황 조회에 포함되도록 변경하고, 관리자·소유권·상태 검증을 거쳐 계정을 ACTIVE로 복구하는 재연결 서비스와 PATCH API를 추가했습니다. Changes플랫폼 계정 재연결
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant PlatformController
participant PlatformServiceImpl
participant PlatformAccount
Client->>PlatformController: PATCH /{orgId}/accounts/{accountId}/reconnect
PlatformController->>PlatformServiceImpl: reconnectPlatform(userId, orgId, accountId)
PlatformServiceImpl->>PlatformAccount: DISCONNECTED 상태 확인
PlatformServiceImpl->>PlatformAccount: reconnect()
PlatformAccount-->>PlatformServiceImpl: ACTIVE 상태 전환
PlatformServiceImpl-->>PlatformController: 재연결 완료
PlatformController-->>Client: 200 OK DataResponse
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformServiceImpl.java (1)
186-210: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win검증 로직이 5개 메서드에 중복되어 있습니다.
userRepository.findById→orgMemberRepository.findByUserIdAndOrgId→ ADMIN 권한 검증 패턴이addNaverAdAccount,getPlatformSyncInfos,updateNaverAdAccount,disconnectPlatform,reconnectPlatform에서 거의 동일하게 반복됩니다. 헬퍼 메서드로 추출하면 유지보수성이 크게 향상됩니다.♻️ 제안하는 리팩토링 — 공통 검증 헬퍼 추출
+ private OrgMember validateAdminMembership(Long userId, Long orgId) { + userRepository.findById(userId) + .orElseThrow(() -> new UserHandler(UserErrorCode.USER_NOT_FOUND)); + OrgMember orgMember = orgMemberRepository.findByUserIdAndOrgId(userId, orgId) + .orElseThrow(() -> new PlatformHandler(PlatformErrorCode.PLATFORM_ORG_MEMBER_NOT_FOUND)); + if (orgMember.getRole() != OrgRole.ADMIN) { + throw new PlatformHandler(PlatformErrorCode.PLATFORM_FORBIDDEN); + } + return orgMember; + } + `@Override` public void reconnectPlatform(Long userId, Long orgId, Long accountId) { - userRepository.findById(userId) - .orElseThrow(() -> new UserHandler(UserErrorCode.USER_NOT_FOUND)); - - OrgMember orgMember = orgMemberRepository.findByUserIdAndOrgId(userId, orgId) - .orElseThrow(() -> new PlatformHandler(PlatformErrorCode.PLATFORM_ORG_MEMBER_NOT_FOUND)); - - if (orgMember.getRole() != OrgRole.ADMIN) { - throw new PlatformHandler(PlatformErrorCode.PLATFORM_FORBIDDEN); - } + validateAdminMembership(userId, orgId);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformServiceImpl.java` around lines 186 - 210, Extract the repeated user existence, organization membership, and ADMIN role checks from addNaverAdAccount, getPlatformSyncInfos, updateNaverAdAccount, disconnectPlatform, and reconnectPlatform into a private helper in PlatformServiceImpl. Replace each duplicated validation sequence with the helper, preserving the existing exception types and validation order.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformServiceImpl.java`:
- Around line 186-210: reconnectPlatform의 조직 소속 검증이 누락되어 다른 조직의 ADMIN이 재연결할 수
있습니다. platformAccount를 조회한 뒤
platformAccount.getOrganization().getId().equals(orgId)를 확인하고 불일치 시 기존 권한 오류를
발생시키세요. 또한 PlatformControllerDocs의 해당 재연결 API 403 응답 설명에 PLATFORM_403_2를 추가하세요.
---
Nitpick comments:
In
`@src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformServiceImpl.java`:
- Around line 186-210: Extract the repeated user existence, organization
membership, and ADMIN role checks from addNaverAdAccount, getPlatformSyncInfos,
updateNaverAdAccount, disconnectPlatform, and reconnectPlatform into a private
helper in PlatformServiceImpl. Replace each duplicated validation sequence with
the helper, preserving the existing exception types and validation order.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3af6ada7-1cc0-47f1-9a0b-bb07c121a1da
📒 Files selected for processing (6)
src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformService.javasrc/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformServiceImpl.javasrc/main/java/com/whereyouad/WhereYouAd/domains/platform/exception/code/PlatformErrorCode.javasrc/main/java/com/whereyouad/WhereYouAd/domains/platform/persistence/entity/PlatformAccount.javasrc/main/java/com/whereyouad/WhereYouAd/domains/platform/presentation/PlatformController.javasrc/main/java/com/whereyouad/WhereYouAd/domains/platform/presentation/docs/PlatformControllerDocs.java
📌 관련 이슈
🚀 개요
프론트 요청에 따라 플랫폼 연동 현황 조회 API 를 개선하고, 재연동 API 를 추가합니다.
📄 작업 내용
📸 스크린샷 / 테스트 결과 (선택)
최초 DB 상태 : id = 2 인 네이버 계정이 DISCONNECTED 상태

연동 현황 조회 시 DISCONNECTED 도 정상 조회 가능

재연동 API 로 요청 시 다시 ACTIVE 상태로 전환 확인



✅ 체크리스트
🔍 리뷰 포인트 (Review Points)
Summary by CodeRabbit
새 기능
오류 개선