Skip to content
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.wayble.server.user.dto;


import com.wayble.server.user.entity.DisabilityType;
import com.wayble.server.user.entity.Gender;
import com.wayble.server.user.entity.MobilityAid;
import com.wayble.server.user.entity.UserType;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -26,11 +28,13 @@ public class UserInfoRegisterRequestDto {
@NotNull(message = "유저 타입은 필수입니다.")
private UserType userType;

private List<String> disabilityType; // 장애 유형, (userType == DISABLED만 값 존재)

private List<String> mobilityAid; // 이동보조수단, (userType == DISABLED만 값 존재)
private List<DisabilityType> disabilityType; // 장애 유형, (userType == DISABLED만 값 존재)
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

강타입 enum 사용으로 개선됨

List<String>에서 List<DisabilityType>, List<MobilityAid>로 변경하여 타입 안전성이 향상되었습니다. 다만 validation 검증이 필요합니다.

다음 스크립트로 enum 값들이 올바르게 정의되어 있는지 확인해주세요:

Also applies to: 34-34


🏁 Script executed:

#!/bin/bash
# enum 정의 확인
ast-grep --pattern 'enum DisabilityType {
  $$$
}'

ast-grep --pattern 'enum MobilityAid {
  $$$
}'

Length of output: 102


다음 스크립트로 Java 소스 전체에서 enum 정의를 다시 확인해주세요.
(이전 ast-grep 결과가 없었으므로 ripgrep으로 재검증)


🏁 Script executed:

#!/bin/bash
# Java 파일에서 enum 정의 위치와 내용을 확인
rg -n "enum\s+DisabilityType" -C2 --glob="*.java"
rg -n "enum\s+MobilityAid" -C2 --glob="*.java"

Length of output: 990


강타입 enum 정의 검증 완료 — Validation 로직 추가 필요

  • src/main/java/com/wayble/server/user/entity/DisabilityType.java
    • DEVELOPMENTAL, VISUAL
  • src/main/java/com/wayble/server/user/entity/MobilityAid.java
    • GUIDE_DOG, CANE

위 enum 정의가 정상 확인되었습니다.
따라서 DTO(src/main/java/com/wayble/server/user/dto/UserInfoRegisterRequestDto.java, 32·34)에서 List<DisabilityType> · List<MobilityAid> 사용은 안전합니다.

다만 아래 사항을 검증하는 Validation 로직을 추가해주세요:

  • userType == DISABLED일 때만 값이 전달되는지
  • null 또는 빈 리스트를 허용할지 여부
  • 리스트 요소에 대해 유효한 enum 값인지
🤖 Prompt for AI Agents
In src/main/java/com/wayble/server/user/dto/UserInfoRegisterRequestDto.java
around line 32, add validation logic to ensure that the List<DisabilityType> and
List<MobilityAid> fields are only populated when userType equals DISABLED.
Implement checks to allow or disallow null or empty lists based on requirements,
and validate that each element in these lists corresponds to a valid enum value.
This can be done using custom validation annotations or manual validation in the
DTO or service layer.


// TODO: 현재 와이어프레임에 유저 이미지 등록하는 로직이 없어서 유저 정보 등록에서 이미지 등록 안하면 해당 필드 추후 삭제
private List<MobilityAid> mobilityAid; // 이동보조수단, (userType == DISABLED만 값 존재)

/* 유저 이미지 등록 관련 (추후에 사용할 수도 있어서 주석처리)
@Pattern(regexp = "^(https?://).*", message = "올바른 URL 형식이어야 합니다.")
private String profileImageUrl;
*/
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.wayble.server.user.dto;

import com.wayble.server.user.entity.DisabilityType;
import com.wayble.server.user.entity.Gender;
import com.wayble.server.user.entity.MobilityAid;
import com.wayble.server.user.entity.UserType;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -14,7 +16,7 @@ public class UserInfoResponseDto {
private String birthDate;
private Gender gender;
private UserType userType;
private List<String> disabilityType; // 복수 선택 가능
private List<String> mobilityAid; // 복수 선택 가능
private String profileImageUrl;
private List<DisabilityType> disabilityType; // 복수 선택 가능
private List<MobilityAid> mobilityAid; // 복수 선택 가능
// private String profileImageUrl; (추후 사용 가능)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.wayble.server.user.dto;

import com.wayble.server.user.entity.DisabilityType;
import com.wayble.server.user.entity.Gender;
import com.wayble.server.user.entity.MobilityAid;
import com.wayble.server.user.entity.UserType;
import jakarta.validation.constraints.Pattern;
import lombok.Getter;
Expand All @@ -13,8 +15,10 @@ public class UserInfoUpdateRequestDto {
private String birthDate; // YYYY-MM-DD (nullable)
private Gender gender; // MALE, FEMALE, UNKNOWN (nullable)
private UserType userType; // GENERAL, DISABLED, COMPANION (nullable)
private List<String> disabilityType; // userType이 DISABLED일 때만 값, 아니면 null
private List<String> mobilityAid; // userType이 DISABLED일 때만 값, 아니면 null
private List<DisabilityType> disabilityType; // userType이 DISABLED일 때만 값, 아니면 null
private List<MobilityAid> mobilityAid; // userType이 DISABLED일 때만 값, 아니면 null
/* 유저 이미지 수정 관련 (추후 사용 가능)
@Pattern(regexp = "^(https?://).*", message = "올바른 URL 형식이어야 합니다.")
private String profileImageUrl; // TODO: 현재 와이어프레임에 유저 이미지 등록하는 로직이 없어서 유저 정보 등록에서 이미지 등록 안하면 해당 필드 추후 삭제
private String profileImageUrl;
*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.wayble.server.user.entity;

public enum DisabilityType {
DEVELOPMENTAL, // 발달장애
VISUAL, // 시각장애
PHYSICAL, // 지체장애
AUDITORY // 청각장애
}
8 changes: 8 additions & 0 deletions src/main/java/com/wayble/server/user/entity/MobilityAid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.wayble.server.user.entity;

public enum MobilityAid {
GUIDE_DOG, // 안내견
CANE, // 지팡이
WHEELCHAIR, // 휠체어
NONE // 없음
}
18 changes: 10 additions & 8 deletions src/main/java/com/wayble/server/user/entity/User.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.wayble.server.user.entity;

import com.wayble.server.common.converter.StringListConverter;
import com.wayble.server.common.entity.BaseEntity;
import com.wayble.server.review.entity.Review;
import jakarta.persistence.*;
Expand Down Expand Up @@ -59,14 +58,17 @@ public class User extends BaseEntity {
@Column(name = "profile_image_url")
private String profileImageUrl;

@Convert(converter = StringListConverter.class)
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "user_disability_type", joinColumns = @JoinColumn(name = "user_id"))
@Enumerated(EnumType.STRING)
@Column(name = "disability_type")
private List<String> disabilityType; // 장애 유형 (발달장애,시각장애,지체장애,청각장애)

private List<DisabilityType> disabilityType = new ArrayList<>(); // 장애 유형 (발달장애,시각장애,지체장애,청각장애)
Comment on lines +61 to +65
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

JPA @ElementCollection 매핑으로 개선됨

@Convert 어노테이션에서 @ElementCollection으로 변경하여 JPA 표준을 따르는 더 나은 매핑 방식으로 개선되었습니다. 별도 테이블로 관리되어 정규화도 향상되었습니다.

기존 데이터가 있다면 마이그레이션 스크립트가 필요할 수 있습니다. 다음 스크립트로 관련 마이그레이션 파일을 확인해주세요:

Also applies to: 68-72


🏁 Script executed:

#!/bin/bash
# 마이그레이션 파일 확인
fd -e sql . | xargs grep -l "user_disability_type\|user_mobility_aid" 2>/dev/null || echo "마이그레이션 파일을 찾을 수 없습니다"

Length of output: 122


DB 마이그레이션 스크립트 누락 확인 및 불필요한 import 제거 필요

  • user_disability_type, user_mobility_aid 테이블 생성용 SQL 마이그레이션 파일이 없습니다.
    → Liquibase/Flyway XML 혹은 .sql 스크립트, 또는 Java 기반 마이그레이션 코드가 있는지 확인하고 없으면 추가해주세요.
  • src/main/java/com/wayble/server/user/entity/User.java에 남아 있는 StringListConverter import를 제거하세요.
  • @ElementCollection 매핑 시 대량 조회 시 N+1 문제나 성능 이슈가 발생할 수 있으므로, 페치 전략(FetchType), @BatchSize 설정 등을 검토해주세요.
🤖 Prompt for AI Agents
In src/main/java/com/wayble/server/user/entity/User.java around lines 62 to 66,
first verify if there are Liquibase, Flyway, or Java migration scripts that
create the user_disability_type and user_mobility_aid tables; if missing, add
appropriate migration files to create these tables. Next, remove the unused
import of StringListConverter from the User.java file. Finally, review the
@ElementCollection mapping for disabilityType to address potential N+1 query
issues by adjusting the fetch strategy or adding @BatchSize annotations to
optimize performance during bulk fetches.


@Convert(converter = StringListConverter.class)
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "user_mobility_aid", joinColumns = @JoinColumn(name = "user_id"))
@Enumerated(EnumType.STRING)
@Column(name = "mobility_aid")
private List<String> mobilityAid; // 이동 보조 수단 (안내견,지팡이,동행인,휠체어)
private List<MobilityAid> mobilityAid = new ArrayList<>(); // 이동보조수단 (안내견,지팡이,휠체어,없음)

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Review> reviewList = new ArrayList<>();
Expand Down Expand Up @@ -121,9 +123,9 @@ public void setNickname(String nickname) {
this.nickname = nickname;
}

public void setDisabilityType(List<String> disabilityType) { this.disabilityType = disabilityType; }
public void setDisabilityType(List<DisabilityType> disabilityType) { this.disabilityType = disabilityType; }

public void setMobilityAid(List<String> mobilityAid) { this.mobilityAid = mobilityAid; }
public void setMobilityAid(List<MobilityAid> mobilityAid) { this.mobilityAid = mobilityAid; }

public void setBirthDate(LocalDate birthDate) { this.birthDate = birthDate; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void registerUserInfo(Long userId, UserInfoRegisterRequestDto dto) {
}
user.setGender(dto.getGender());
user.setUserType(dto.getUserType());
user.updateProfileImageUrl(dto.getProfileImageUrl());
// (추후 사용 가능) user.updateProfileImageUrl(dto.getProfileImageUrl());

if (dto.getUserType() == UserType.DISABLED) {
// 장애 유형,이동보조수단 설정
Expand Down Expand Up @@ -81,10 +81,11 @@ public void updateUserInfo(Long userId, UserInfoUpdateRequestDto dto) {
user.setUserType(dto.getUserType());
}

// 유저 프로필 이미지 수정
/* 유저 프로필 이미지 수정
if (dto.getProfileImageUrl() != null) {
user.updateProfileImageUrl(dto.getProfileImageUrl());
}
*/

UserType finalUserType = dto.getUserType() != null ? dto.getUserType() : user.getUserType();
if (finalUserType == UserType.DISABLED) {
Expand Down Expand Up @@ -117,7 +118,7 @@ public UserInfoResponseDto getUserInfo(Long userId) {
.userType(user.getUserType())
.disabilityType(user.getDisabilityType())
.mobilityAid(user.getMobilityAid())
.profileImageUrl(user.getProfileImageUrl())
// (추후 사용 가능) .profileImageUrl(user.getProfileImageUrl())
.build();
}
}
Loading