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