package com.bjsxt.service.impl;

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

@Service
public class UsersServiceImpl implements UsersService {

    @Autowired
    private UsersMapper usersMapper;

    /**
     * 用户登录
     * @param username
     * @param userpwd
     * @return
     */
    @Override
    public Users userLogin(String username, String userpwd) {
        Users users = this.usersMapper.selectUsersByName(username);
        if (users == null){
            //用户名不存在
            throw new UsersException("用户不存在");
        }else if (!users.getUserpwd().equals(userpwd)){
            //密码有误
            throw new UsersException("密码有误");

        }
        return users;
    }
}
