-
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
Changes from all commits
927cf2d
5e10f32
d4ff81b
3ba34fa
4b58cb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.wayble.server.user.dto; | ||
|
|
||
| import com.wayble.server.user.entity.Gender; | ||
| import com.wayble.server.user.entity.LoginType; | ||
| import com.wayble.server.user.entity.UserType; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| public record UserRegisterRequestDto( | ||
| String nickname, | ||
| String username, | ||
| String email, | ||
| String password, | ||
| LocalDate birthDate, | ||
| Gender gender, | ||
| LoginType loginType, | ||
| UserType userType | ||
| ) {} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.wayble.server.user.entity; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Entity | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Table(name = "disability") | ||
| public class Disability { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "disability_id") | ||
| private Long id; | ||
|
|
||
| @Column(name = "name", nullable = false, unique = true) | ||
| private String name; // ex: 발달장애,시각장애,지체장애,청각장애 | ||
|
|
||
| @OneToMany(mappedBy = "disability", cascade = CascadeType.ALL, orphanRemoval = true) | ||
| private List<UserDisabilityMapping> userDisabilityMappings = new ArrayList<>(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.wayble.server.user.entity; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
|
|
||
| @Getter | ||
| @Entity | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Table(name = "user_disability_mapping", | ||
| uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "disability_id"})) | ||
| public class UserDisabilityMapping { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "user_id", nullable = false) | ||
| private User user; | ||
|
|
||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "disability_id", nullable = false) | ||
| private Disability disability; // 장애 유형 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,5 +3,11 @@ | |
| import com.wayble.server.user.entity.User; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface UserRepository extends JpaRepository<User, Long> { | ||
|
|
||
| Optional<User> findByEmail(String email); | ||
|
|
||
| boolean existsByEmail(String email); | ||
|
Comment on lines
+10
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)의 회원 가입/이메일 검증 로직에 • 대상 위치
🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. @seung-in-Yoo 네, 좋습니다! 이메일 중복 검사 로직을 서비스 계층에 구현하시면 됩니다. 🧠 Learnings used |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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 어노테이션을 추가하여 데이터 무결성을 보장해야 합니다.
다음과 같이 검증 어노테이션을 추가하세요:
📝 Committable suggestion
🤖 Prompt for AI Agents
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 도움이 되어서 기쁩니다! 검증 로직을 미리 제안할 수 있어서 다행이네요. 구현하실 때 추가로 궁금한 점이 있으시면 언제든 말씀해 주세요! 🐰
🧠 Learnings used