package cn.minbb.iot.service.impl;

import cn.minbb.iot.model.User;
import cn.minbb.iot.model.repository.UserRepository;
import cn.minbb.iot.service.UserService;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    private UserRepository userRepository;

    public UserServiceImpl(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @Override
    public User saveOne(User user) {
        return userRepository.save(user);
    }

    @Override
    public User findUserByUsername(String username) {
        return null == username ? null : userRepository.findOneByUsername(username);
    }
}
