package com.ruoyi.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.mapper.InfoUserMapper;
import com.ruoyi.system.domain.InfoUser;
import com.ruoyi.system.service.IInfoUserService;

/**
 * 用户信息Service业务层处理
 *
 * @author ruoyi
 * @date 2023-06-25
 */
@Service
public class InfoUserServiceImpl extends ServiceImpl<BaseMapper<InfoUser>,InfoUser> implements IInfoUserService
{

    @Override
    public InfoUser getinfouserName(String userName) {
        //查询数据库存不存在用户
        QueryWrapper<InfoUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_name",userName);
        return getOne(queryWrapper);

    }

    @Override
    public InfoUser getinfoPhone(String phone) {
        //查询数据库存不存在用户
        QueryWrapper<InfoUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("phone",phone);
        return getOne(queryWrapper);

    }

    @Override
    public InfoUser getuser(String phone) {
        //查询数据库存不存在用户
        QueryWrapper<InfoUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("phone",phone);
        queryWrapper.eq("del_flag", "0");
        return getOne(queryWrapper);
    }
    @Autowired
    private InfoUserMapper infoUserMapper;

    /**
     * 查询用户信息
     *
     * @param userId 用户信息主键
     * @return 用户信息
     */
    @Override
    public InfoUser selectInfoUserByUserId(Long userId)
    {
        return infoUserMapper.selectInfoUserByUserId(userId);
    }

    /**
     * 查询用户信息列表
     *
     * @param infoUser 用户信息
     * @return 用户信息
     */
    @Override
    public List<InfoUser> selectInfoUserList(InfoUser infoUser)
    {
        return infoUserMapper.selectInfoUserList(infoUser);
    }

    /**
     * 新增用户信息
     *
     * @param infoUser 用户信息
     * @return 结果
     */
    @Override
    public int insertInfoUser(InfoUser infoUser)
    {
        return infoUserMapper.insertInfoUser(infoUser);
    }

    /**
     * 修改用户信息
     *
     * @param infoUser 用户信息
     * @return 结果
     */
    @Override
    public int updateInfoUser(InfoUser infoUser)
    {
        return infoUserMapper.updateInfoUser(infoUser);
    }

    /**
     * 批量删除用户信息
     *
     * @param userIds 需要删除的用户信息主键
     * @return 结果
     */
    @Override
    public int deleteInfoUserByUserIds(Long[] userIds)
    {
        return infoUserMapper.deleteInfoUserByUserIds(userIds);
    }

    /**
     * 删除用户信息信息
     *
     * @param userId 用户信息主键
     * @return 结果
     */
    @Override
    public int deleteInfoUserByUserId(Long userId)
    {
        return infoUserMapper.deleteInfoUserByUserId(userId);
    }
}
