Skip to content

feat: [NDGL-148] 유저 엔티티 소셜 로그인 필드 추가#78

Merged
WooJJam merged 3 commits into
feature/NDGL-147-Server-Spring-Security-도입from
feature/NDGL-148-Server-유저-엔티티-소셜-로그인-필드-추가
Jun 1, 2026

Hidden character warning

The head ref may contain hidden characters: "feature/NDGL-148-Server-\uc720\uc800-\uc5d4\ud2f0\ud2f0-\uc18c\uc15c-\ub85c\uadf8\uc778-\ud544\ub4dc-\ucd94\uac00"
Merged

feat: [NDGL-148] 유저 엔티티 소셜 로그인 필드 추가#78
WooJJam merged 3 commits into
feature/NDGL-147-Server-Spring-Security-도입from
feature/NDGL-148-Server-유저-엔티티-소셜-로그인-필드-추가

Conversation

@WooJJam
Copy link
Copy Markdown
Member

@WooJJam WooJJam commented May 29, 2026

🤖 이 PR은 AI를 사용하여 자동 생성되었습니다.

요약

소셜 로그인 정보를 도입해 소셜 사용자 생성/조회와 중복 방지를 지원하도록 도메인·DB·서비스를 확장합니다.

변경 내용

  • SocialProvider enum을 추가
  • User 엔티티에 provider, providerId, email 칼럼을 추가
  • users 테이블에 (provider, providerId) 유니크 제약을 추가
  • 도메인·매퍼·리포지토리·서비스에 소셜 사용자 생성/조회 흐름을 추가
  • User 엔티티의 fcmToken 제약을 변경(nullable 허용)

참고 사항

기존 데이터에서 (provider, providerId) 중복 가능성 확인 및 마이그레이션 준비가 필요합니다.

Summary by CodeRabbit

새로운 기능

  • 카카오 및 애플 소셜 로그인 서비스 통합
  • 소셜 계정을 통한 신규 사용자 생성 및 기존 사용자 조회 기능 추가
  • 소셜 로그인 사용자의 이메일 및 닉네임 정보 관리 지원

Review Change Stack

@WooJJam WooJJam self-assigned this May 29, 2026
@WooJJam WooJJam added feat 새로운 기능 추가 ai-generated AI로 생성한 PR labels May 29, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 34aea1e4-86f3-45d0-ae2a-fad9f94ff9a9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/NDGL-148-Server-유저-엔티티-소셜-로그인-필드-추가

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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
`@domain/domain-service/src/main/java/com/yapp/ndgl/domain/user/service/UserDomainService.java`:
- Around line 39-48: createSocialUser currently calls
userRepository.save(UserMapper.toEntity(user)) without handling
concurrent-creation constraint violations, so a DataIntegrityViolationException
during save can map to 500 instead of 409; wrap the save call in a try/catch
inside createSocialUser, catch DataIntegrityViolationException, inspect the
cause chain for org.hibernate.exception.ConstraintViolationException or
SQLIntegrityConstraintViolationException (or the constraint name/message
referring to provider/provider_id), and convert it into a domain/API conflict
error (e.g., throw an ApiException or specific ConflictException that maps to
CommonErrorCode.DATA_INTEGRITY_VIOLATION / 409). Reference: createSocialUser,
User.createSocialUser, userRepository.save, UserEntity, ApiExceptionHandler,
CommonErrorCode.DATA_INTEGRITY_VIOLATION.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 78743c32-9d10-4e19-9062-fb774279629d

📥 Commits

Reviewing files that changed from the base of the PR and between e4ae1c9 and 088b138.

📒 Files selected for processing (6)
  • common/src/main/java/com/yapp/ndgl/common/type/SocialProvider.java
  • domain/domain-rdb/src/main/java/com/yapp/ndgl/domain/user/entity/UserEntity.java
  • domain/domain-rdb/src/main/java/com/yapp/ndgl/domain/user/repository/UserRepository.java
  • domain/domain-service/src/main/java/com/yapp/ndgl/domain/user/User.java
  • domain/domain-service/src/main/java/com/yapp/ndgl/domain/user/mapper/UserMapper.java
  • domain/domain-service/src/main/java/com/yapp/ndgl/domain/user/service/UserDomainService.java

Comment on lines +39 to +48
@Transactional
public User createSocialUser(
final SocialProvider provider,
final String providerId,
final String email) {
String nickname = UserNicknameGenerator.generate();
User user = User.createSocialUser(provider, providerId, email, nickname);
UserEntity savedEntity = userRepository.save(UserMapper.toEntity(user));
return UserMapper.toDomain(savedEntity);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# createSocialUser / findByProviderAndProviderId 호출부 확인
rg -nP -C5 '\b(createSocialUser|findByProviderAndProviderId)\s*\(' --type=java -g '!**/UserDomainService.java'

Repository: YAPP-Github/NDGL-BE

Length of output: 2037


🏁 Script executed:

#!/bin/bash
rg -nP '\.createSocialUser\s*\(' --type=java
rg -nP '\.findByProviderAndProviderId\s*\(' --type=java

Repository: YAPP-Github/NDGL-BE

Length of output: 417


🏁 Script executed:

#!/bin/bash
# 1) 해당 서비스의 createSocialUser/중복선검사 흐름 확인
sed -n '1,140p' domain/domain-service/src/main/java/com/yapp/ndgl/domain/user/service/UserDomainService.java

# 2) DataIntegrityViolationException/ConstraintViolationException 예외 매핑 확인
rg -n --hidden --no-ignore-vcs 'DataIntegrityViolationException|ConstraintViolationException|CommonErrorCode\.DATA_INTEGRITY_VIOLATION' --type=java

# 3) 유니크 제약(provider, provider_id) 실제 어노테이션 확인
rg -n --hidden --no-ignore-vcs 'provider[_-]?provider_id|provider_id|providerId|`@UniqueConstraint`|uniqueConstraints\s*=' \
  --type=java domain/domain-rdb/src/main/java/com/yapp/ndgl/domain/user

Repository: YAPP-Github/NDGL-BE

Length of output: 5768


🏁 Script executed:

#!/bin/bash
# ApiExceptionHandler: DataIntegrityViolationException 처리 로직 확인
sed -n '130,210p' application/src/main/java/com/yapp/ndgl/application/common/exception/ApiExceptionHandler.java

# CommonErrorCode: DATA_INTEGRITY_VIOLATION의 상태코드/메시지 확인
rg -n "DATA_INTEGRITY_VIOLATION" -S application/src/main/java domain/src/main/java

Repository: YAPP-Github/NDGL-BE

Length of output: 3813


소셜 계정 중복 생성 시 예외 처리(409/500) 및 레이스 대응 확인 필요
UserEntity(provider, provider_id) 유니크 제약이 있고, createSocialUser는 별도 선검사 없이 바로 save를 수행하므로 동시 요청 시 DataIntegrityViolationException이 발생할 수 있습니다. 전역 ApiExceptionHandlerDataIntegrityViolationExceptioncauseorg.hibernate.exception.ConstraintViolationException일 때만 CommonErrorCode.DATA_INTEGRITY_VIOLATION409(CONFLICT) 처리하고, 그 외에는 500으로 떨어집니다. 레이스 상황에서 실제로 해당 cause가 항상 매핑되는지(또는 호출부/도메인에서 일관된 예외로 변환하는지) 확인이 필요합니다.

🤖 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
`@domain/domain-service/src/main/java/com/yapp/ndgl/domain/user/service/UserDomainService.java`
around lines 39 - 48, createSocialUser currently calls
userRepository.save(UserMapper.toEntity(user)) without handling
concurrent-creation constraint violations, so a DataIntegrityViolationException
during save can map to 500 instead of 409; wrap the save call in a try/catch
inside createSocialUser, catch DataIntegrityViolationException, inspect the
cause chain for org.hibernate.exception.ConstraintViolationException or
SQLIntegrityConstraintViolationException (or the constraint name/message
referring to provider/provider_id), and convert it into a domain/API conflict
error (e.g., throw an ApiException or specific ConflictException that maps to
CommonErrorCode.DATA_INTEGRITY_VIOLATION / 409). Reference: createSocialUser,
User.createSocialUser, userRepository.save, UserEntity, ApiExceptionHandler,
CommonErrorCode.DATA_INTEGRITY_VIOLATION.

@WooJJam WooJJam merged commit e4142af into feature/NDGL-147-Server-Spring-Security-도입 Jun 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated AI로 생성한 PR feat 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant