-
Notifications
You must be signed in to change notification settings - Fork 1
[refactor] 유저 엔티티 연관관계 정의 및 회원가입용 DTO 구현 #43
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
Walkthrough사용자 등록과 관련된 DTO와 엔티티 구조가 전면적으로 개편되었습니다. 불필요한 빈 DTO가 삭제되고, 실제 사용자 등록 요청을 위한 DTO와 장애 정보 관리용 엔티티, 사용자-장애 매핑 엔티티가 추가되었습니다. User 엔티티와 레포지토리에도 필드, 관계, 쿼리 메소드가 확장되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Controller
participant UserRepository
participant DisabilityRepository
Client->>Controller: UserRegisterRequestDto 전송
Controller->>UserRepository: 이메일 중복 확인 (existsByEmail)
UserRepository-->>Controller: 중복 여부 반환
alt 중복 아님
Controller->>UserRepository: User 엔티티 저장
Controller->>DisabilityRepository: 장애 정보 매핑 저장 (필요 시)
DisabilityRepository-->>Controller: 저장 완료
end
Controller-->>Client: 등록 결과 반환
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/main/java/com/wayble/server/user/entity/Disability.java (1)
22-23: 주석의 표기 수정이 필요합니다.주석의 장애 유형 예시에서 "발달장애"를 "발달장애"로 표기하는 것이 적절합니다.
- private String name; // ex: 발달장애,시각장애,지체장애,청각장애 + private String name; // ex: 발달장애, 시각장애, 지체장애, 청각장애src/main/java/com/wayble/server/user/entity/User.java (2)
36-38: 비밀번호 암호화 구현이 필요합니다.TODO 주석으로 표시된 비밀번호 암호화가 보안상 중요합니다.
Spring Security의 BCryptPasswordEncoder를 사용한 비밀번호 암호화 구현을 도와드릴 수 있습니다. 새로운 이슈를 생성하여 이를 추적하시겠습니까?
55-56: 프로필 이미지 URL 검증을 고려해보세요.profileImageUrl 필드에 URL 형식 검증을 추가하는 것을 권장합니다.
+import jakarta.validation.constraints.Pattern; + +@Pattern(regexp = "^https?://.*\\.(jpg|jpeg|png|gif|webp)$", message = "유효한 이미지 URL이 아닙니다") @Column(name = "profile_image_url") private String profileImageUrl;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/main/java/com/wayble/server/user/dto/UserRegisterDto.java(0 hunks)src/main/java/com/wayble/server/user/dto/UserRegisterRequestDto.java(1 hunks)src/main/java/com/wayble/server/user/entity/Disability.java(1 hunks)src/main/java/com/wayble/server/user/entity/User.java(2 hunks)src/main/java/com/wayble/server/user/entity/UserDisabilityMapping.java(1 hunks)src/main/java/com/wayble/server/user/repository/UserRepository.java(1 hunks)
💤 Files with no reviewable changes (1)
- src/main/java/com/wayble/server/user/dto/UserRegisterDto.java
🧰 Additional context used
🧠 Learnings (4)
src/main/java/com/wayble/server/user/repository/UserRepository.java (1)
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
src/main/java/com/wayble/server/user/entity/Disability.java (1)
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
src/main/java/com/wayble/server/user/entity/User.java (1)
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
src/main/java/com/wayble/server/user/entity/UserDisabilityMapping.java (1)
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
🔇 Additional comments (5)
src/main/java/com/wayble/server/user/entity/Disability.java (1)
25-26: 연관관계 설정이 적절합니다.cascade = CascadeType.ALL과 orphanRemoval = true 설정이 적절하며, 장애 엔티티가 삭제될 때 관련 매핑도 함께 정리됩니다.
src/main/java/com/wayble/server/user/entity/UserDisabilityMapping.java (2)
11-12: 유니크 제약조건 설정이 적절합니다.사용자와 장애 유형의 조합에 대한 유니크 제약조건으로 중복 매핑을 효과적으로 방지합니다.
20-22: 지연 로딩 설정이 적절합니다.FetchType.LAZY 사용으로 불필요한 데이터 로딩을 방지하여 성능을 최적화했습니다.
src/main/java/com/wayble/server/user/entity/User.java (2)
33-34: 이메일 유니크 제약조건 추가가 적절합니다.중복 이메일 방지를 위한 unique = true 설정이 적절하며, UserRepository의 existsByEmail 메소드와 잘 연동됩니다.
61-62: 장애 관련 연관관계 설정이 적절합니다.UserDisabilityMapping과의 OneToMany 관계 설정이 올바르며, cascade와 orphanRemoval 옵션이 적절합니다.
| public record UserRegisterRequestDto( | ||
| String nickname, | ||
| String username, | ||
| String email, | ||
| String password, | ||
| LocalDate birthDate, | ||
| Gender gender, | ||
| LoginType loginType, | ||
| UserType userType | ||
| ) {} |
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.
🛠️ Refactor suggestion
입력 검증 어노테이션 추가가 필요합니다.
회원가입 요청 DTO에 Bean Validation 어노테이션을 추가하여 데이터 무결성을 보장해야 합니다.
다음과 같이 검증 어노테이션을 추가하세요:
+import jakarta.validation.constraints.*;
+
public record UserRegisterRequestDto(
+ @NotBlank(message = "닉네임은 필수입니다")
+ @Size(max = 8, message = "닉네임은 8자 이하여야 합니다")
String nickname,
+ @NotBlank(message = "사용자명은 필수입니다")
String username,
+ @NotBlank(message = "이메일은 필수입니다")
+ @Email(message = "유효한 이메일 형식이 아닙니다")
String email,
+ @NotBlank(message = "비밀번호는 필수입니다")
+ @Size(min = 8, message = "비밀번호는 8자 이상이어야 합니다")
String password,
+ @NotNull(message = "생년월일은 필수입니다")
+ @Past(message = "생년월일은 과거 날짜여야 합니다")
LocalDate birthDate,
+ @NotNull(message = "성별은 필수입니다")
Gender gender,
+ @NotNull(message = "로그인 타입은 필수입니다")
LoginType loginType,
+ @NotNull(message = "사용자 타입은 필수입니다")
UserType userType
) {}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public record UserRegisterRequestDto( | |
| String nickname, | |
| String username, | |
| String email, | |
| String password, | |
| LocalDate birthDate, | |
| Gender gender, | |
| LoginType loginType, | |
| UserType userType | |
| ) {} | |
| import jakarta.validation.constraints.*; | |
| public record UserRegisterRequestDto( | |
| @NotBlank(message = "닉네임은 필수입니다") | |
| @Size(max = 8, message = "닉네임은 8자 이하여야 합니다") | |
| String nickname, | |
| @NotBlank(message = "사용자명은 필수입니다") | |
| String username, | |
| @NotBlank(message = "이메일은 필수입니다") | |
| @Email(message = "유효한 이메일 형식이 아닙니다") | |
| String email, | |
| @NotBlank(message = "비밀번호는 필수입니다") | |
| @Size(min = 8, message = "비밀번호는 8자 이상이어야 합니다") | |
| String password, | |
| @NotNull(message = "생년월일은 필수입니다") | |
| @Past(message = "생년월일은 과거 날짜여야 합니다") | |
| LocalDate birthDate, | |
| @NotNull(message = "성별은 필수입니다") | |
| Gender gender, | |
| @NotNull(message = "로그인 타입은 필수입니다") | |
| LoginType loginType, | |
| @NotNull(message = "사용자 타입은 필수입니다") | |
| UserType userType | |
| ) {} |
🤖 Prompt for AI Agents
In src/main/java/com/wayble/server/user/dto/UserRegisterRequestDto.java around
lines 9 to 18, the UserRegisterRequestDto record lacks Bean Validation
annotations to ensure input data integrity. Add appropriate validation
annotations such as @NotBlank for strings like nickname, username, email, and
password, @Email for the email field, @NotNull for birthDate, gender, loginType,
and userType fields to enforce non-null constraints. This will guarantee that
incoming user registration data meets the required validation rules.
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.
이것도 이제 구현하려고 했는데 알려줘서 고마워~
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.
@seung-in-Yoo 도움이 되어서 기쁩니다! 검증 로직을 미리 제안할 수 있어서 다행이네요. 구현하실 때 추가로 궁금한 점이 있으시면 언제든 말씀해 주세요! 🐰
/| /|
( :v: )
|(_)|
| |
/ \
🧠 Learnings used
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
| Optional<User> findByEmail(String email); | ||
|
|
||
| boolean existsByEmail(String email); |
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.
💡 Verification agent
🧩 Analysis chain
이메일 관련 메소드 구현이 적절합니다.
Spring Data JPA 메소드 네이밍 컨벤션을 잘 따르고 있으며, Optional을 사용한 안전한 반환값 처리가 좋습니다.
다음 스크립트로 이메일 중복 검사 로직이 실제로 서비스 레이어에서 올바르게 사용되는지 확인해보겠습니다:
🏁 Script executed:
#!/bin/bash
# 이메일 중복 검사 로직 사용처 확인
rg -A 10 "existsByEmail|findByEmail" --type javaLength of output: 412
서비스 계층에서 이메일 중복 검사 로직 미사용 확인
서비스 계층(예: UserService)의 회원 가입/이메일 검증 로직에 existsByEmail(또는 findByEmail) 호출이 없습니다. 해당 로직을 호출하도록 구현을 추가해주세요.
• 대상 위치
- src/main/java/com/wayble/server/user/service/UserService.java (또는 회원 가입을 처리하는 유사 서비스 클래스)
- 회원 가입 메소드(register 등) 내에
existsByEmail(email)호출 및 예외 처리/에러 응답 로직 추가
🤖 Prompt for AI Agents
In src/main/java/com/wayble/server/user/service/UserService.java around the user
registration method (e.g., register), add a call to UserRepository's
existsByEmail(email) to check for duplicate emails before proceeding with
registration. If existsByEmail returns true, throw an appropriate exception or
return an error response to prevent duplicate user creation. This ensures the
service layer properly validates email uniqueness using the repository method.
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.
이제 구현할거야
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.
@seung-in-Yoo 네, 좋습니다! 이메일 중복 검사 로직을 서비스 계층에 구현하시면 됩니다. existsByEmail 메소드를 활용해서 회원가입 시 이메일 중복을 방지하는 로직을 추가해주세요. 구현하시면서 궁금한 점이 있으시면 언제든지 말씀해주세요!
🧠 Learnings used
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
작업내용
현재 구현되어있지 않는 유저 엔티티의 연관관계를 정의하고, 이메일 중복방지 로직을 추가하였습니다.
장애 관련 (매핑 포함) 엔티티 설계를 완료하였습니다.
Summary by CodeRabbit
신규 기능
버그 수정