package com.example.service.impl;

import com.example.exception.UserException;
import com.example.mapper.UserMapper;
import com.example.pojo.User;
import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper  userMapper;

    /*
    * 用户登入
    * */
    @Override
    public User userLogin(User user) {
        User u = this.userMapper.selectUser(user);
        if(u == null || u.getUsername().length() <=0 ){
            throw new UserException("用户名或者密码错误,请检查");
        }
        return u;
    }

    @Override
    public User findUserById(int id) {
        return this.userMapper.selectUserById(id);
    }
}
