Skip to content

Conversation

@shinheekim
Copy link
Contributor

@shinheekim shinheekim commented Dec 29, 2025

🔎 작업 내용

User, Profile 도메인 분리

  • User 엔티티에서 프로필 관련 필드 제거 및 Profile 도메인으로 분리
  • Profile 엔티티 및 Repository 추가 - User와 1:1 관계로 프로필 정보 관리
  • OAuth 로그인 시 User 생성과 함께 빈 Profile도 자동 생성

API 구현

  • 프로필 초기 설정 API 구현 (PUT /api/v1/me/profile) - 닉네임, 성별, 전화번호, 생년월일 설정
  • 닉네임 중복 방지를 위한 비관적 잠금(PESSIMISTIC_WRITE) 적용 - Race condition 방지
  • 전화번호 인증 토큰 검증 로직 추가 - JWT 토큰을 통한 인증된 전화번호 확인

기타 수정사항

  • 기획 변경으로 띄어쓰기 없는 랜덤 닉네임 생성 방식 적용

➕ 이슈 링크

🧑‍💻 예정 작업

📝 체크리스트

  • 브랜치 이름은 feature/개발내용 형식으로 작성했는가?
  • 커밋 메시지는 feat: 커밋 내용 형식으로 작성했는가?
  • 작업 전 Issue를 작성했는가?
  • dev 브랜치로 병합을 요청했는가?
  • 불필요한 주석과 공백은 제거했는가?
  • 코드 리뷰어의 피드백을 반영했는가?
  • 테스트를 진행했는가?
  • 테스트 코드를 작성했는가?

- Profile 엔티티 생성 (nickname, profileImage, gender, phoneNumber, birthday, selfIntroduction)
- User와 OneToOne 관계 설정
- ErrorCode에 PROFILE_NOT_FOUND 추가
- ProfileRepository 인터페이스 생성
- findByUser, findByUser_Id 메서드 추가
- existsByNickname, existsByPhoneNumber 메서드 추가
- User 엔티티에서 nickname, profileImage, gender, phoneNumber, birthday 제거
- User와 Profile을 OneToOne 관계로 연결 (mappedBy 사용)
- UserRepository에서 existsByNickname, existsByPhoneNumber 제거
- UserController → ProfileController, UserApiDocs → ProfileApiDocs
- UserService → NicknameService
- UserUpdateNicknameRequest → NicknameUpdateRequest
- UserCheckNicknameResponse → NicknameValidateResponse
- Gender, AgeRange enum을 profile.domain.enums로 이동
- InvalidGenderException을 profile.exception으로 이동
- 닉네임 관련 utils, validator를 profile 패키지로 이동
- NicknameService에서 ProfileRepository 사용하도록 수정
- getProfileByUserId 메서드 버그 수정 (findById → findByUser_Id)
- createNewUser 메서드에서 User 생성 후 Profile도 함께 생성
- OAuth에서 받은 profileImage를 Profile에 저장
- nickname, gender, phoneNumber, birthday는 null로 초기화
- Post 도메인: Gender, AgeRange import 경로 변경 (user.enums → profile.domain.enums)
- PostRepositoryImpl: InvalidGenderException import 경로 변경
- CommentResponse: User 대신 Profile에서 nickname, profileImage 조회
- UserInfo: User.getProfile()을 통해 Profile 정보 조회하도록 변경
- PhoneVerificationService: UserRepository 대신 ProfileRepository 사용
- UserRepositoryTest: Profile 생성 로직 추가, Gender import 경로 수정
- UserServiceTest → NicknameServiceTest로 변경사항 반영
- PhoneVerificationServiceTest: ProfileRepository 사용하도록 변경
- JwtTokenProvider에 validateVerificationToken 메서드 추가
- verification token의 유효성 검증 및 전화번호 일치 여부 확인
- setupInitialProfile 메서드 추가
- marketingAgree 필드 제거
- 닉네임, 성별, 전화번호, 생년월일 설정 기능 구현
- ProfileSetupRequest DTO 생성
- nickname, gender, phoneNumber, birthday, verificationToken 필드 포함
- marketingAgree 필드 제거
- setupInitialProfile 메서드 구현
- 닉네임 중복 검증
- 전화번호 인증 토큰 검증
- 전화번호 중복 검증
- 생년월일 파싱 로직 추가
- marketingAgree 관련 로직 제거
- 불필요한 주석 제거
- PUT /api/v1/me/profile 엔드포인트 추가
- PATCH에서 PUT으로 변경
- ProfileSetupRequest로 프로필 정보 받아 처리
- NicknameService -> ProfileService로 변경된 것에 맞춰 테스트 코드 수정
- Profile이 항상 존재한다는 전제로 null 체크 제거
@shinheekim shinheekim force-pushed the feat/#107-signup-final-api branch from 881f9f0 to 700cc6c Compare December 29, 2025 19:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements profile initial setup functionality by separating User and Profile domains. The main changes include creating a new Profile entity with a 1:1 relationship to User, implementing a profile setup API with pessimistic locking for nickname uniqueness, and updating the random nickname generation to remove spaces.

Key Changes

  • Separated profile-related fields (nickname, gender, phone number, birthday, profile image) from User entity into a new Profile entity with 1:1 relationship
  • Implemented PUT /api/v1/me/profile API endpoint for initial profile setup with phone verification token validation and pessimistic locking for nickname race condition prevention
  • Updated random nickname generation to produce nicknames without spaces (e.g., "용감한여행자1234" → "용감한여행자1234")

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/main/java/com/dduru/gildongmu/user/domain/User.java Removed profile-related fields and added OneToOne relationship to Profile
src/main/java/com/dduru/gildongmu/profile/domain/Profile.java New Profile entity with user reference and profile fields
src/main/java/com/dduru/gildongmu/profile/repository/ProfileRepository.java New repository with pessimistic locking query for nickname uniqueness
src/main/java/com/dduru/gildongmu/profile/service/ProfileService.java Moved nickname logic from UserService and added setupInitialProfile method
src/main/java/com/dduru/gildongmu/profile/controller/ProfileController.java Renamed from UserController and added profile setup endpoint
src/main/java/com/dduru/gildongmu/auth/service/OauthAuthService.java Updated to create empty Profile alongside User during OAuth registration
src/main/java/com/dduru/gildongmu/user/dto/UserInfo.java Updated to fetch profile data from Profile entity instead of User
src/main/java/com/dduru/gildongmu/common/jwt/JwtTokenProvider.java Added validateVerificationToken method for phone verification
src/main/java/com/dduru/gildongmu/profile/utils/NicknameGenerator.java Removed space between adjective and noun in nickname generation
src/test/java/com/dduru/gildongmu/profile/service/ProfileServiceTest.java Comprehensive test coverage for profile setup scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GIL-DONG-MU GIL-DONG-MU deleted a comment from Copilot AI Dec 29, 2025
@GIL-DONG-MU GIL-DONG-MU deleted a comment from Copilot AI Dec 29, 2025
@GIL-DONG-MU GIL-DONG-MU deleted a comment from Copilot AI Dec 29, 2025
@GIL-DONG-MU GIL-DONG-MU deleted a comment from Copilot AI Dec 29, 2025
@GIL-DONG-MU GIL-DONG-MU deleted a comment from Copilot AI Dec 29, 2025
@GIL-DONG-MU GIL-DONG-MU deleted a comment from Copilot AI Dec 29, 2025
@GIL-DONG-MU GIL-DONG-MU deleted a comment from Copilot AI Dec 29, 2025
Copy link
Collaborator

@jaejoong0529 jaejoong0529 left a comment

Choose a reason for hiding this comment

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

수고하셨습니당! 프로필 초기 설정 잘하셨네요

@jaejoong0529 jaejoong0529 merged commit bbb491b into dev Dec 30, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔧 BE ✨ feature 새 기능 개발 / 요구사항

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 최종 회원가입(개인정보 저장) API 구현

3 participants