package service.impl;

import exception.UsersException;
import mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Users;
import service.UsersService;

@Service
public class UsersLoginImpl implements UsersService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public Users usersLogin(Users users) {
        Users users1 = this.userMapper.selectUserById(users.getUserid());
        if (!users1.getUsername().equals(users.getUsername())){
            throw new UsersException("用户名错误");
        }else if (!users1.getUserPassword().equals(users.getUserPassword())){
            throw new UsersException("密码错误");
        }
        return users1;
    }
}
