Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ public class UserService {

@Autowired
private UserRepository repo;

private static ObjectNotFoundException get() {
return new ObjectNotFoundException("Objeto não encontrado");
}

public List<User> findAll() {
return repo.findAll();
}

public User findById(String id) {
Optional<User> obj = repo.findById(id);
return obj.orElseThrow(() -> new ObjectNotFoundException("Objeto não encontrado"));
Optional<User> obj = userRepository.findById(id);
return obj.orElseThrow(UserService::get);
}

public User insert(User obj) {
Expand Down