package com.cpxt.biz.service.impl;

import java.util.Arrays;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.cpxt.biz.domain.BizCustomerShop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cpxt.biz.mapper.BizCustomerUserMapper;
import com.cpxt.biz.domain.BizCustomerUser;
import com.cpxt.biz.service.IBizCustomerUserService;

/**
 * 用户Service业务层处理
 * 
 * @author YIN
 * @date 2024-12-16
 */
@Service
public class BizCustomerUserServiceImpl implements IBizCustomerUserService 
{
    @Autowired
    private BizCustomerUserMapper bizCustomerUserMapper;

    /**
     * 查询用户
     * 
     * @param id 用户主键
     * @return 用户
     */
    @Override
    public BizCustomerUser selectBizCustomerUserById(Long id)
    {
        return bizCustomerUserMapper.selectById(id);
    }

    /**
     * 查询用户列表
     * 
     * @param bizCustomerUser 用户
     * @return 用户
     */
    @Override
    public List<BizCustomerUser> selectBizCustomerUserList(BizCustomerUser bizCustomerUser)
    {
        LambdaQueryWrapper<BizCustomerUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BizCustomerUser::getStatus,1);
        return bizCustomerUserMapper.selectList(queryWrapper);
    }

    /**
     * 新增用户
     * 
     * @param bizCustomerUser 用户
     * @return 结果
     */
    @Override
    public int insertBizCustomerUser(BizCustomerUser bizCustomerUser)
    {
        return bizCustomerUserMapper.insert(bizCustomerUser);
    }

    /**
     * 修改用户
     * 
     * @param bizCustomerUser 用户
     * @return 结果
     */
    @Override
    public int updateBizCustomerUser(BizCustomerUser bizCustomerUser)
    {
        return bizCustomerUserMapper.updateById(bizCustomerUser);
    }

    /**
     * 批量删除用户
     * 
     * @param ids 需要删除的用户主键
     * @return 结果
     */
    @Override
    public int deleteBizCustomerUserByIds(Long[] ids)
    {
        UpdateWrapper<BizCustomerUser> updateWrapper = new UpdateWrapper<>();
        updateWrapper.in("id", (Object[]) ids);
        updateWrapper.set("status","2"); //状态改为删除
        return bizCustomerUserMapper.update(null,updateWrapper);
    }

    /**
     * 删除用户信息
     * 
     * @param id 用户主键
     * @return 结果
     */
    @Override
    public int deleteBizCustomerUserById(Long id)
    {
        UpdateWrapper<BizCustomerUser> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id", id);
        updateWrapper.set("status","2"); //状态改为删除
        return bizCustomerUserMapper.update(null,updateWrapper);
    }
}
