Skip to content

Refactor/#176 플랫폼 연동 현황 조회 개선 & 재연동 API 추가#177

Merged
ojy0903 merged 9 commits into
developfrom
refactor/#176
Jul 10, 2026
Merged

Refactor/#176 플랫폼 연동 현황 조회 개선 & 재연동 API 추가#177
ojy0903 merged 9 commits into
developfrom
refactor/#176

Conversation

@ojy0903

@ojy0903 ojy0903 commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

📌 관련 이슈

🚀 개요

이번 PR에서 변경된 핵심 내용을 요약해주세요.

프론트 요청에 따라 플랫폼 연동 현황 조회 API 를 개선하고, 재연동 API 를 추가합니다.

📄 작업 내용

구체적인 작업 내용을 설명해주세요.

  • 플랫폼 연동 현황 조회에서 DISCONNECTED 상태인 계정 정보도 조회 가능하도록 수정
  • 플랫폼 정보 삭제 전 재연동 API 추가

📸 스크린샷 / 테스트 결과 (선택)

결과물 확인을 위한 사진이나 테스트 로그를 첨부해주세요.

최초 DB 상태 : id = 2 인 네이버 계정이 DISCONNECTED 상태
image

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

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

✅ 체크리스트

  • 브랜치 전략(GitHub Flow)을 준수했나요?
  • 메서드 단위로 코드가 잘 쪼개져 있나요?
  • 테스트 통과 확인
  • 서버 실행 확인
  • API 동작 확인

🔍 리뷰 포인트 (Review Points)

리뷰어가 중점적으로 확인했으면 하는 부분을 적어주세요. (P1~P4 적용 가이드)

  • 프론트 요청에 따라 연동 현황 조회에서 Soft Delete 인 계정도 보이도록 수정했고, 재연동 API 를 추가했습니다.
  • 수정 후 정상적으로 조회 및 재연동 됨을 확인하여 바로 머지 하겠습니다.

💬 리뷰어 가이드 (P-Rules)
P1: 필수 반영 (Critical) - 버그 가능성, 컨벤션 위반. 해결 전 머지 불가.
P2: 적극 권장 (Recommended) - 더 나은 대안 제시. 가급적 반영 권장.
P3: 제안 (Suggestion) - 아이디어 공유. 반영 여부는 드라이버 자율.
P4: 단순 확인/칭찬 (Nit) - 사소한 오타, 칭찬 등 피드백.

Summary by CodeRabbit

  • 새 기능

    • 연결이 해제된 광고 계정을 다시 연동할 수 있는 기능을 추가했습니다.
    • 조직 관리자만 계정 재연동을 수행할 수 있습니다.
    • 재연동 API를 통해 계정 상태가 활성 상태로 복구됩니다.
    • 연결 해제된 계정도 플랫폼 동기화 정보에서 확인할 수 있습니다.
  • 오류 개선

    • 연결되지 않은 계정이 아닌 경우 재연동을 제한하고 안내 메시지를 제공합니다.
    • 계정 소유자 관련 오류 메시지를 재연동 상황에 맞게 개선했습니다.

@ojy0903 ojy0903 self-assigned this Jul 10, 2026
@ojy0903 ojy0903 added 📡 API API 명세 및 엔드포인트 관련 작업 ♻️ Refactor 코드 구조 개선 labels Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ojy0903, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9a755b61-7b89-4cc2-9879-e97ff5bab63f

📥 Commits

Reviewing files that changed from the base of the PR and between d3c7b09 and d2cb288.

📒 Files selected for processing (2)
  • src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformServiceImpl.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/platform/presentation/docs/PlatformControllerDocs.java

Walkthrough

DISCONNECTED 플랫폼 계정이 연동 현황 조회에 포함되도록 변경하고, 관리자·소유권·상태 검증을 거쳐 계정을 ACTIVE로 복구하는 재연결 서비스와 PATCH API를 추가했습니다.

Changes

플랫폼 계정 재연결

Layer / File(s) Summary
연동 현황 조회 범위 확장
src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformServiceImpl.java
플랫폼 연동 현황 조회에서 DISCONNECTED 계정을 제외하던 필터를 제거했습니다.
재연결 상태 전환 및 서비스 흐름
src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformService.java, src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformServiceImpl.java, src/main/java/com/whereyouad/WhereYouAd/domains/platform/persistence/entity/PlatformAccount.java, src/main/java/com/whereyouad/WhereYouAd/domains/platform/exception/code/PlatformErrorCode.java
재연결 서비스 계약을 추가하고, 관리자 권한·계정 소유권·DISCONNECTED 상태를 검증한 뒤 PlatformAccountACTIVE로 변경하도록 구현했습니다.
재연결 API 노출
src/main/java/com/whereyouad/WhereYouAd/domains/platform/presentation/PlatformController.java, src/main/java/com/whereyouad/WhereYouAd/domains/platform/presentation/docs/PlatformControllerDocs.java
PATCH /api/platform/{orgId}/accounts/{accountId}/reconnect 엔드포인트와 성공·오류 응답 문서를 추가했습니다.

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
Loading

Possibly related PRs

Suggested labels: ✨ Feature

Suggested reviewers: kingmingyu, jinnieusLab

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 연동 현황 조회 개선과 재연동 API 추가라는 핵심 변경을 정확히 요약합니다.
Description check ✅ Passed 관련 이슈, 개요, 작업 내용, 스크린샷/테스트, 체크리스트, 리뷰 포인트가 모두 포함되어 템플릿을 대부분 충족합니다.
Linked Issues check ✅ Passed DISCONNECTED 계정 조회 포함과 재연동 API 추가라는 #176의 핵심 요구사항이 모두 반영되었습니다.
Out of Scope Changes check ✅ Passed 에러 코드, 서비스, 컨트롤러, Swagger 변경도 재연동 기능 구현에 직접 필요한 범위로 보이며 불필요한 변경은 없습니다.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#176

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.findByIdorgMemberRepository.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

📥 Commits

Reviewing files that changed from the base of the PR and between a808c4f and d3c7b09.

📒 Files selected for processing (6)
  • src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformService.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/platform/domain/service/PlatformServiceImpl.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/platform/exception/code/PlatformErrorCode.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/platform/persistence/entity/PlatformAccount.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/platform/presentation/PlatformController.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/platform/presentation/docs/PlatformControllerDocs.java

@ojy0903 ojy0903 merged commit 35a0edf into develop Jul 10, 2026
1 check passed
@ojy0903 ojy0903 deleted the refactor/#176 branch July 10, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📡 API API 명세 및 엔드포인트 관련 작업 ♻️ Refactor 코드 구조 개선

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: 플랫폼 연동 현황 조회 개선 & 재연동 API 추가

1 participant