Compare commits
2 Commits
d8b7943646
...
master
Author | SHA1 | Date | |
---|---|---|---|
a663a73ff1 | |||
2d27ebea35 |
@ -1,7 +1,7 @@
|
||||
package co.jp.app.dto;
|
||||
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank; // 或 javax.validation.constraints.NotBlank
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
@ -31,16 +31,10 @@ public class UserService implements UserDetailsService {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
|
||||
public UserEntity registerNewUser(@NotNull RegistrationDto registrationDto) throws BusinessException {
|
||||
|
||||
if (userRepository.existsByEmail(registrationDto.getEmail())) {
|
||||
throw new BusinessException(ResultCode.USER_USERNAME_ALREADY_EXISTS,"error: Name" + registrationDto.getName() + " had been used");
|
||||
}
|
||||
|
||||
//密码最短6位限制
|
||||
if (registrationDto.getPassword() == null || registrationDto.getPassword().length() < 6) {
|
||||
throw new BusinessException(ResultCode.USER_PASSWORD_TOO_SHORT);
|
||||
throw new BusinessException(ResultCode.USER_EMAIL_ALREADY_EXISTS,"error: Email" + registrationDto.getEmail() + " had been used");
|
||||
}
|
||||
|
||||
UserEntity newUser = new UserEntity();
|
||||
@ -50,8 +44,6 @@ public class UserService implements UserDetailsService {
|
||||
|
||||
return userRepository.save(newUser);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
|
Reference in New Issue
Block a user