Merge branch 'BE/userinfo' into 'backend'

feat: 회원정보 변경시 이메일 중복 검사

See merge request s11-webmobile1-sub2/S11P12A701!140
This commit is contained in:
박정민 2024-08-09 14:19:50 +09:00
commit 7f0a76d8cc
3 changed files with 11 additions and 5 deletions

View File

@ -65,7 +65,7 @@ public class UserController {
userService.changePassword(passwordDto, userId); userService.changePassword(passwordDto, userId);
return ResponseEntity.ok("Password changed successfully"); return ResponseEntity.ok("Password changed successfully");
} catch (Exception e) { } catch (Exception e) {
return ResponseEntity.badRequest().body(e.getMessage()); return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body(e.getMessage());
} }
} }

View File

@ -74,6 +74,12 @@ public class UserServiceImpl implements UserService {
User user = userRepository.findById(id).orElseThrow(IllegalArgumentException::new); User user = userRepository.findById(id).orElseThrow(IllegalArgumentException::new);
if (isEmailExist(infoDto.getEmail())) {
throw new IllegalArgumentException("이미 사용 중인 이메일입니다.");
}
if (infoDto.getName() != null) if (infoDto.getName() != null)
user.setName(infoDto.getName()); user.setName(infoDto.getName());