Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/main/java/com/wayble/server/user/dto/UserRegisterDto.java

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
) {}
Comment on lines +9 to +18
Copy link

@coderabbitai coderabbitai bot Jul 16, 2025

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.

Suggested change
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.

Copy link
Member Author

Choose a reason for hiding this comment

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

이것도 이제 구현하려고 했는데 알려줘서 고마워~

Copy link

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 없이 사용 가능하다.

27 changes: 27 additions & 0 deletions src/main/java/com/wayble/server/user/entity/Disability.java
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<>();
}
14 changes: 9 additions & 5 deletions src/main/java/com/wayble/server/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ public class User extends BaseEntity {

private String username;

@Column(nullable = false)
@Column(nullable = false, unique = true)
private String email;

// TODO: 비밀번호 암호화 필요
@Column(nullable = false)
private String password;

@Column(name = "birth_date", columnDefinition = "DATE")
Expand All @@ -44,19 +45,22 @@ public class User extends BaseEntity {
private Gender gender;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
@Column(name = "login_type", nullable = false)
private LoginType loginType;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
@Column(name = "user_type", nullable = false)
private UserType userType;

@Column(name = "profile_image_url")
private String profileImageUrl;

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Review> reviewList = new ArrayList<>();

// TODO 장애 종류 필드 등록 필요
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<UserDisabilityMapping> userDisabilities = new ArrayList<>();

// TODO 프로필 이미지 관련 작업 필요

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<UserPlace> userPlaces = new ArrayList<>();
Expand Down
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
Expand Up @@ -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
Copy link

@coderabbitai coderabbitai bot Jul 16, 2025

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 java

Length 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.

Copy link
Member Author

Choose a reason for hiding this comment

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

이제 구현할거야

Copy link

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 없이 사용 가능하다.

}
Loading