package rs.ac.uns.acs.nais.GreetingApplication.service;


import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import rs.ac.uns.acs.nais.GreetingApplication.entity.User;
import rs.ac.uns.acs.nais.GreetingApplication.repository.UserRepository;

@Service
public class UserService {    
	
	@Autowired
    private UserRepository userRepository;

    public String greetUser(Long userId) {
    	Optional<User> optionalUser = userRepository.findById(userId);
    	return optionalUser.map(user -> "Hi, " + user.getFirstName()).orElse("User not found");

    }
}
