package service.impl;

import mapper.UsersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Users;
import pojo.UsersExample;
import service.UsersService;

import java.util.List;

@Service
public class UserServiceImpl implements UsersService {
    @Autowired
    private UsersMapper usersMapper;
    @Override
    public void addUsers(Users users) {
        this.usersMapper.insert(users);
    }

    @Override
    public List<Users> findUsers() {
        UsersExample usersExample = new UsersExample();
        List<Users> list = this.usersMapper.selectByExample(usersExample);
        return list;
    }

    @Override
    public Users findUserById(int userid) {
        Users users = this.usersMapper.selectByPrimaryKey(userid);
        return users;
    }

    @Override
    public void modifyUsers(Users users) {
        this.usersMapper.updateByPrimaryKey(users);
    }

    @Override
    public void dropUsers(int userid) {
        this.usersMapper.deleteByPrimaryKey(userid);
    }
}
