feat: Dedicated exception on user creation
This commit is contained in:
parent
52ae2789fc
commit
c7ef32e28d
3 changed files with 22 additions and 3 deletions
|
@ -0,0 +1,11 @@
|
|||
package eu.ztsh.wymiana.exception;
|
||||
|
||||
import eu.ztsh.wymiana.web.model.UserCreateRequest;
|
||||
|
||||
public class UserAlreadyExistsException extends RuntimeException {
|
||||
|
||||
public UserAlreadyExistsException(UserCreateRequest entity) {
|
||||
super("User with PESEL %s already exists".formatted(entity.pesel()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,21 @@
|
|||
package eu.ztsh.wymiana.service;
|
||||
|
||||
import eu.ztsh.wymiana.data.repository.UserRepository;
|
||||
import eu.ztsh.wymiana.model.User;
|
||||
import eu.ztsh.wymiana.web.model.UserCreateRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
|
||||
public User create(@Valid UserCreateRequest request) {
|
||||
throw new IllegalStateException("Not impplemented yet");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue