refactor: 도달 불가 코드 및 중복 DB 조회 제거#341
Conversation
- UserService.userAuth(): DB 쿼리 조건에 이미 검증된 비밀번호 이중 확인 블록 제거 - UbuntuAccountService.deleteUbuntuAccount(): onStatus가 이미 404를 처리하므로 catch 내 WebClientResponseException NOT_FOUND 분기 제거 - RequestCommandService: createModificationRequest/createSingleChangeRequest에서 이미 로드된 originalRequest.getUser()로 불필요한 userRepository 재조회 대체
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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.
Pull request overview
이 PR은 도달 불가(dead) 코드와 중복 DB 조회를 제거해 서비스 로직을 단순화하고 불필요한 비용/분기를 줄이는 리팩터링입니다.
Changes:
UserService.userAuth()에서 쿼리 단계에서 이미 비밀번호 일치가 보장되는 추가 검증 분기를 제거UbuntuAccountService.deleteUbuntuAccount()에서 404 예외 분기 제거 및 unused import 정리RequestCommandService에서 요청 소유권 검증 이후 동일 User를 재조회하던 로직 제거
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/java/DGU_AI_LAB/admin_be/domain/users/service/UserService.java | 인증 로직에서 중복 비밀번호 검증(도달 불가/불필요 가능) 제거로 흐름 단순화 |
| src/main/java/DGU_AI_LAB/admin_be/domain/requests/service/UbuntuAccountService.java | 404 처리 분기 제거 및 예외 처리 정리(단, BusinessException 래핑 이슈 확인 필요) |
| src/main/java/DGU_AI_LAB/admin_be/domain/requests/service/RequestCommandService.java | 소유권 검증 후 동일 User 재조회 제거로 불필요한 DB 접근 감소 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } catch (Exception e) { | ||
| if (!(e instanceof WebClientResponseException && ((WebClientResponseException)e).getStatusCode() == HttpStatus.NOT_FOUND)) { | ||
| log.error("사용자 삭제 API 호출 중 예기치 않은 오류: {}", username, e); | ||
| throw new BusinessException("사용자 삭제 API 호출 오류", ErrorCode.INTERNAL_SERVER_ERROR); | ||
| } | ||
| log.error("사용자 삭제 API 호출 중 예기치 않은 오류: {}", username, e); | ||
| throw new BusinessException("사용자 삭제 API 호출 오류", ErrorCode.INTERNAL_SERVER_ERROR); | ||
| } |
Summary
Closes #335
UserService.userAuth():findByUbuntuUsernameAndUbuntuPasswordBase64쿼리가 이미 비밀번호 일치를 보장하므로 이중 확인 블록 제거 (L75-80)UbuntuAccountService.deleteUbuntuAccount():onStatus가 404를Mono.empty()로 처리하므로 catch 내WebClientResponseException NOT_FOUND분기는 도달 불가 — 제거 및 unused import 정리RequestCommandService.createModificationRequest/createSingleChangeRequest: userId 소유권 검증 직후에originalRequest.getUser()로 동일 User를 얻을 수 있으므로userRepository.findById(userId)재조회 제거Test plan
UserService.userAuth(): username/password 불일치 시USER_NOT_FOUND반환 확인UbuntuAccountService.deleteUbuntuAccount(): 404 응답 시 예외 없이 정상 종료 확인, 500 응답 시BusinessException발생 확인RequestCommandService.createModificationRequest: 정상 변경 요청 생성 확인