Skip to content

Commit

Permalink
HOTFIX: 학번, 전화번호 중복 체크 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hyxklee committed Jul 30, 2024
1 parent 043401b commit bc68f8d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/main/java/leets/weeth/domain/user/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import leets.weeth.domain.user.entity.User;
import leets.weeth.domain.user.mapper.UserMapper;
import leets.weeth.domain.user.repository.UserRepository;
import leets.weeth.global.common.error.exception.custom.StudentIdExistsException;
import leets.weeth.global.common.error.exception.custom.TelExistsException;
import leets.weeth.global.common.error.exception.custom.UserExistsException;
import leets.weeth.global.common.error.exception.custom.UserNotFoundException;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -124,10 +126,11 @@ public void validate(String email){
}

private void validate(UserDTO.SignUp requestDto) {
if(userRepository.existsByEmail(requestDto.email()) || // 이메일 중복
userRepository.existsByStudentId(requestDto.studentId()) || // 학번 중복
userRepository.existsByTel(requestDto.tel())) // 전화번호 중복
throw new UserExistsException();
if(userRepository.existsByStudentId(requestDto.studentId())){
throw new StudentIdExistsException();
} else if(userRepository.existsByTel(requestDto.tel())){
throw new TelExistsException();
}
}

private void validate(Long userId, UserDTO.Update dto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public enum ExceptionType {
NOTICE_TYPE_NOT_MATCH(HttpStatus.BAD_REQUEST, NoticeTypeNotMatchException.class),
ACCOUNT_NOT_FOUND(HttpStatus.BAD_REQUEST, AccountNotFoundException.class),
ACCOUNT_ALREADY_EXISTS(HttpStatus.BAD_REQUEST, AccountExistsException.class),
ATTENDANCE_EVENT_TYPE_NOT_MATCH(HttpStatus.BAD_REQUEST, AttendanceEventTypeNotMatchException.class);
ATTENDANCE_EVENT_TYPE_NOT_MATCH(HttpStatus.BAD_REQUEST, AttendanceEventTypeNotMatchException.class),
STUDENT_ID_ALREADY_EXISTS(HttpStatus.BAD_REQUEST, StudentIdExistsException.class),
TEL_ALREADY_EXISTS(HttpStatus.BAD_REQUEST, TelExistsException.class);

private final HttpStatus httpStatus;
private final Class<? extends Exception> type;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package leets.weeth.global.common.error.exception.custom;

import jakarta.persistence.EntityNotFoundException;

public class StudentIdExistsException extends EntityNotFoundException {
public StudentIdExistsException() {super("이미 가입된 학번입니다.");}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package leets.weeth.global.common.error.exception.custom;

import jakarta.persistence.EntityNotFoundException;

public class TelExistsException extends EntityNotFoundException {
public TelExistsException() {super("이미 가입된 전화번호 입니다.");}
}

0 comments on commit bc68f8d

Please sign in to comment.