Skip to content

[fix] 회원 복구 시 비활성화된 사업장 재활성화#188

Merged
geunyong16 merged 1 commit into
mainfrom
fix/187-restore-workplaces-on-account-recovery
May 14, 2026
Merged

[fix] 회원 복구 시 비활성화된 사업장 재활성화#188
geunyong16 merged 1 commit into
mainfrom
fix/187-restore-workplaces-on-account-recovery

Conversation

@geunyong16
Copy link
Copy Markdown
Collaborator

@geunyong16 geunyong16 commented May 14, 2026

🔖 관련 GitHub Issue

📝 변경 사항

주요 변경 내용

  • UserWithdrawServicerestoreEmployerWorkplaces() 메서드 추가
  • AuthService.restoreWithKakao()에서 user.restore() 직후 사업장 재활성화 호출
  • 관련 단위 테스트 추가 (AuthServiceTest, UserWithdrawServiceTest)

상세 설명

버그 원인

탈퇴 시 withdrawEmployer()가 고용주의 모든 WorkplaceisActive=false로 비활성화하지만, 복구 시 restoreWithKakao()User.deletedAt = null만 되돌리고 사업장을 재활성화하지 않았습니다.

그 결과 복구 후 사업장 목록은 비어있는 것처럼 보이지만, DB에는 isActive=false인 row가 남아있어 동일 business_number로 사업장을 재등록하려 하면 UNIQUE 제약 위반이 발생했습니다.

수정 방법

UserWithdrawService.restoreEmployerWorkplaces(User user)를 추가하여 EMPLOYER 타입 복구 시 workplaceRepository.findByEmployerIdAndIsActive(employerId, false)로 비활성 사업장을 조회해 일괄 activate()합니다.

  • 계약·근무기록은 기존과 동일하게 복구하지 않습니다 (다른 근로자 데이터 일관성 보호)
  • Workplace.activate() 메서드 및 findByEmployerIdAndIsActive() 쿼리는 기존 코드 재사용

📸 스크린샷 (선택사항)

백엔드 버그 수정으로 해당 없음

✅ 체크리스트

  • PR 제목이 형식에 맞는가? (유형: 작업 요약)
  • 코드가 정상적으로 빌드되는가?
  • 새로운 기능에 대한 테스트 코드를 작성했는가?
  • 모든 테스트가 통과하는가?
  • 코드 스타일 가이드를 따랐는가?
  • 관련 문서를 업데이트했는가?

🔗 관련 PR

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 카카오 탈퇴 계정 복구 시 고용주 사용자의 비활성화된 직장(사업장)이 자동으로 재활성화됩니다. 비즈니스 번호 재등록도 함께 진행됩니다.
    • 사용자 설정은 복구 중에도 유지됩니다.
  • 테스트

    • 고용주 계정 복구 시나리오에 대한 테스트 커버리지를 추가했습니다.

Review Change Stack

- UserWithdrawService에 restoreEmployerWorkplaces() 추가
- restoreWithKakao에서 user.restore() 직후 사업장 재활성화 호출
- 탈퇴 후 복구 시 동일 사업자번호로 사업장 재등록할 수 없던 버그(#187) 해결
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fea70c6a-af27-417a-b239-f84a5fad2054

📥 Commits

Reviewing files that changed from the base of the PR and between 5bff0ce and 07e1662.

📒 Files selected for processing (4)
  • src/main/java/com/example/paycheck/domain/auth/service/AuthService.java
  • src/main/java/com/example/paycheck/domain/user/service/UserWithdrawService.java
  • src/test/java/com/example/paycheck/domain/auth/service/AuthServiceTest.java
  • src/test/java/com/example/paycheck/domain/user/service/UserWithdrawServiceTest.java

검토 개요

고용주 계정의 회원 탈퇴 후 복구 시 비활성화된 사업장을 자동으로 재활성화하는 기능을 추가합니다. 이는 이슈 #187에서 보고된 동일 사업자번호로 사업장 재등록 불가 문제를 해결합니다.

변경 사항

고용주 사업장 복원

Layer / File(s) 요약
사업장 복원 메서드 구현
src/main/java/com/example/paycheck/domain/user/service/UserWithdrawService.java
새로운 restoreEmployerWorkplaces(User user) 메서드를 구현하여 고용주의 비활성화된 사업장을 조회하고 활성화 상태로 변경합니다. 비고용주 사용자이거나 고용주 엔티티가 없는 경우 조기 종료합니다.
복구 플로우 통합 및 문서화
src/main/java/com/example/paycheck/domain/auth/service/AuthService.java
restoreWithKakao에서 기본 사용자 복구 이후 사업장 복원을 호출하도록 통합합니다. 복구 흐름 문서를 업데이트하여 고용주 사업장 복원(사업자번호 재등록 포함), UserSettings 유지, 계약/근무기록 미자동복원을 명시합니다.
테스트 커버리지
src/test/java/com/example/paycheck/domain/auth/service/AuthServiceTest.java, src/test/java/com/example/paycheck/domain/user/service/UserWithdrawServiceTest.java
고용주 계정 복구 시 restoreEmployerWorkplaces 호출을 검증하는 테스트를 추가합니다. 사업장 재활성화 및 근로자 사용자 호출 시 무동작을 검증합니다.

관련 가능성 있는 PR

  • Team-PayCheck/PayCheck-backend#184: 동일한 AuthService.restoreWithKakao 복구 엔드포인트 및 기본 탈퇴 해제 동작을 추가하는 PR로, 본 PR이 이를 확장하여 고용주 사업장 복원 기능을 추가합니다.

  • Team-PayCheck/PayCheck-backend#186: AuthService.restoreWithKakao 카카오 탈퇴 계정 복구 관련 변경이 있으며, 본 PR의 고용주 대상 restoreEmployerWorkplaces(...) 호출이 #186의 복구 엔드포인트/서비스 로직과 직접 연관됩니다.

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.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 PR 제목은 변경사항의 핵심을 명확하게 요약하고 있으며, '[fix]' 형식과 '회원 복구 시 비활성화된 사업장 재활성화'라는 구체적인 설명으로 주요 변경사항을 잘 나타내고 있습니다.
Description check ✅ Passed PR 설명은 관련 이슈, 주요 변경 내용, 상세 설명(버그 원인과 수정 방법), 그리고 체크리스트를 포함하여 저장소의 템플릿 구조를 대부분 따르고 있습니다.
Linked Issues check ✅ Passed PR의 모든 코딩 관련 요구사항이 충족되었습니다: restoreEmployerWorkplaces() 메서드 추가, restoreWithKakao()에서의 호출, 단위 테스트 추가로 이슈 #187의 UNIQUE 제약 문제를 해결합니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 이슈 #187(회원 복구 시 비활성화된 사업장 재활성화)의 범위 내에 있으며, 사업장 복구 로직과 관련된 필요한 테스트만 추가되었습니다.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/187-restore-workplaces-on-account-recovery

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.

@geunyong16 geunyong16 merged commit 7621de9 into main May 14, 2026
2 checks passed
@geunyong16 geunyong16 deleted the fix/187-restore-workplaces-on-account-recovery branch May 14, 2026 00:29
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.

[BUG] 회원 탈퇴 후 복구 시 동일 사업자번호로 사업장 재등록 불가 (UNIQUE 제약 위반)

1 participant