-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 프로필 초기 설정 API 구현 #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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 체크 제거
881f9f0 to
700cc6c
Compare
There was a problem hiding this 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/profileAPI 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.
src/main/java/com/dduru/gildongmu/profile/service/ProfileService.java
Outdated
Show resolved
Hide resolved
src/main/java/com/dduru/gildongmu/profile/service/ProfileService.java
Outdated
Show resolved
Hide resolved
jaejoong0529
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니당! 프로필 초기 설정 잘하셨네요
🔎 작업 내용
User, Profile 도메인 분리
API 구현
PUT /api/v1/me/profile) - 닉네임, 성별, 전화번호, 생년월일 설정기타 수정사항
➕ 이슈 링크
🧑💻 예정 작업
📝 체크리스트
feature/개발내용형식으로 작성했는가?feat: 커밋 내용형식으로 작성했는가?dev브랜치로 병합을 요청했는가?