MOSU feat: phoneNumber format에 맞춰서 find#319
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Summary of Changes
Hello @wlgns12370, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
이 PR은 OAuth 사용자 정보 처리 로직을 개선하여, 전화번호를 사용하여 기존 사용자를 찾을 때 전화번호 형식을 일관되게 유지하도록 변경합니다. 이를 통해 데이터 정합성을 높이고, 전화번호 기반 사용자 조회 시 발생할 수 있는 불일치를 줄입니다. 또한, 특정 예외 처리 로직을 제거하여 코드의 가독성과 유지보수성을 향상시킵니다.
Highlights
- 전화번호 형식 통일 및 조회 로직 개선:
OAuthUserPersistenceProcessor에서 사용자 조회 시 전화번호를PhoneNumberUtil.formatPhoneNumber를 사용하여 일관된 형식으로 변환한 후 조회하도록 변경되었습니다. - 예외 처리 간소화:
DataIntegrityViolationException에 대한 명시적인try-catch블록과CustomRuntimeException관련 코드가 제거되어, 예외 처리 흐름이 간소화되었습니다.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
| return userRepository.findByPhoneNumber( | ||
| PhoneNumberUtil.formatPhoneNumber(info.phoneNumber())) | ||
| .map(existingUser -> { | ||
| existingUser.updateOAuthUser( | ||
| info.gender(), | ||
| info.name(), | ||
| PhoneNumberUtil.formatPhoneNumber(info.phoneNumber()), | ||
| info.birthDay(), | ||
| info.marketingAgreed()); | ||
| return existingUser; | ||
| }) | ||
| .orElseGet(() -> { | ||
| final UserJpaEntity newUser = UserJpaEntity.builder() | ||
| .loginId(info.email()) | ||
| .gender(info.gender()) | ||
| .name(info.name()) | ||
| .birth(info.birthDay()) | ||
| .phoneNumber(PhoneNumberUtil.formatPhoneNumber(info.phoneNumber())) | ||
| .userRole(UserRole.ROLE_PENDING) | ||
| .provider(AuthProvider.KAKAO) | ||
| .agreedToMarketing(info.marketingAgreed()) | ||
| .build(); | ||
| return userRepository.save(newUser); | ||
| }); |
There was a problem hiding this comment.
이 메서드에는 두 가지 개선점이 있습니다.
-
PhoneNumberUtil.formatPhoneNumber(info.phoneNumber())가 여러 번 호출되고 있습니다. 포맷된 전화번호를 변수에 저장하여 재사용하면 코드가 더 깔끔해지고 중복 호출을 피할 수 있습니다. -
이전 코드에 있던
DataIntegrityViolationException에 대한try-catch블록이 제거되었습니다. 사용자를 전화번호로 먼저 조회하더라도, 다른 사용자가 동일한loginId(이메일)를 가지고 있을 경우userRepository.save()에서DataIntegrityViolationException이 발생할 수 있습니다. 이 예외를 처리하여USER_ALREADY_EXISTS와 같은 명확한 오류를 반환하는 것이 좋습니다.
아래와 같이 수정하는 것을 제안합니다. 이 변경을 적용하려면 제거된 DataIntegrityViolationException, CustomRuntimeException, ErrorCode import를 다시 추가해야 합니다.
final String formattedPhoneNumber = PhoneNumberUtil.formatPhoneNumber(info.phoneNumber());
try {
return userRepository.findByPhoneNumber(formattedPhoneNumber)
.map(existingUser -> {
existingUser.updateOAuthUser(
info.gender(),
info.name(),
formattedPhoneNumber,
info.birthDay(),
info.marketingAgreed());
return existingUser;
})
.orElseGet(() -> {
final UserJpaEntity newUser = UserJpaEntity.builder()
.loginId(info.email())
.gender(info.gender())
.name(info.name())
.birth(info.birthDay())
.phoneNumber(formattedPhoneNumber)
.userRole(UserRole.ROLE_PENDING)
.provider(AuthProvider.KAKAO)
.agreedToMarketing(info.marketingAgreed())
.build();
return userRepository.save(newUser);
});
} catch (org.springframework.dao.DataIntegrityViolationException ex) {
throw new life.mosu.mosuserver.global.exception.CustomRuntimeException(life.mosu.mosuserver.global.exception.ErrorCode.USER_ALREADY_EXISTS);
}
No description provided.