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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@

public class UserConverter {

// 이메일 회원가입
public static SignupResponseDTO toSignupResponseDTO(User user) {
return SignupResponseDTO.builder()
.role(user.getRole())
.userId(user.getId())
.email(user.getEmail())
.nameId(user.getNameId())
.nickname(user.getNickname())
.marketingAgreed(user.getMarketingAgreed())
.notificationAgreed(user.getNotificationAgreed())
.build();
}

public static LoginResponseDTO toLoginResultDTO(User user, String accessToken, String refreshToken) {
return LoginResponseDTO.builder()
.role(user.getRole())
Expand Down Expand Up @@ -119,5 +132,4 @@ public static CheckNicknameResponseDTO toCheckNicknameResponseDto(String nicknam
.isDuplicate(isDuplicate)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ public class SignupResponseDTO {
private String nickname; // 닉네임
private Boolean marketingAgreed; // 마케팅 수신 동의 여부
private Boolean notificationAgreed; // 알림 수신 동의 여부
private String message; // 예: "회원가입이 완료되었습니다."
}

Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ public class UserServiceImpl implements UserService{
public SignupResponseDTO signup(SignupRequestDTO request) {
// 이메일 중복 검사
if (userRepository.existsByEmail(request.getEmail())) {
throw new IllegalArgumentException("이미 사용 중인 이메일입니다.");
throw new ExceptionHandler(ErrorStatus.DUPLICATE_EMAIL);
Copy link
Member

Choose a reason for hiding this comment

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

ErrorStatus 임포트 할 때 import static EatPic.spring.global.common.code.status.ErrorStatus.*; 이런 식으로 해서 그냥 DUPLICATE_NICKNAME 에러 상수만 호출하는 식으로 추후에 리펙토링 하면 좋을 것 같습니다. 수고하셨습니당~

}

// 닉네임 중복 검사
if (userRepository.existsByNickname(request.getNickname())) {
throw new IllegalArgumentException("이미 사용 중인 닉네임입니다.");
throw new ExceptionHandler(ErrorStatus.DUPLICATE_NICKNAME);
}

// 아이디 중복 검사
if (userRepository.existsByNameId(request.getNameId())) {
throw new IllegalArgumentException("이미 사용 중인 아이디입니다.");
throw new ExceptionHandler(ErrorStatus.DUPLICATE_NAMEID);
}

// 저장
Expand All @@ -77,16 +77,7 @@ public SignupResponseDTO signup(SignupRequestDTO request) {
userBadgeService.initializeUserBadges(savedUser);

// DTO로 응답 생성
return SignupResponseDTO.builder()
.role(request.getRole())
.userId(savedUser.getId())
.email(savedUser.getEmail())
.nameId(savedUser.getNameId())
.nickname(savedUser.getNickname())
.marketingAgreed(savedUser.getMarketingAgreed())
.notificationAgreed(savedUser.getNotificationAgreed())
.message("회원가입이 완료되었습니다.")
.build();
return UserConverter.toSignupResponseDTO(savedUser);
}

// 로그인
Expand Down
Loading