package com.ics.admin.service.impl.meeting;

import java.util.List;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ics.admin.mapper.meeting.StaffCustomerMapper;
import com.ics.admin.domain.meeting.StaffCustomer;
import com.ics.admin.service.meeting.IStaffCustomerService;

/**
 * 用户企业Service业务层处理
 * 
 * @author ics
 * @date 2024-04-08
 */
@Service
public class StaffCustomerServiceImpl extends ServiceImpl<StaffCustomerMapper, StaffCustomer> implements IStaffCustomerService {
    @Autowired
    private StaffCustomerMapper staffCustomerMapper;

    /**
     * 查询用户企业
     * 
     * @param id 用户企业ID
     * @return 用户企业
     */
    @Override
    public StaffCustomer selectStaffCustomerById(Long id) {
        return staffCustomerMapper.selectById(id);
    }

    /**
     * 查询用户企业列表
     * 
     * @param staffCustomer 用户企业
     * @return 用户企业
     */
    @Override
    public List<StaffCustomer> selectStaffCustomerList(StaffCustomer staffCustomer) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.like(staffCustomer.getIcsCustomerId() != null,"ics_customer_id",staffCustomer.getIcsCustomerId());
        queryWrapper.like(staffCustomer.getStaffId() !=null,"staff_id",staffCustomer.getStaffId());
        return staffCustomerMapper.selectList(queryWrapper);
    }

    /**
     * 新增用户企业
     * 
     * @param staffCustomer 用户企业
     * @return 结果
     */
    @Override
    public int insertStaffCustomer(StaffCustomer staffCustomer) {
        return staffCustomerMapper.insert(staffCustomer);
    }

    /**
     * 修改用户企业
     * 
     * @param staffCustomer 用户企业
     * @return 结果
     */
    @Override
    public int updateStaffCustomer(StaffCustomer staffCustomer) {
        return staffCustomerMapper.updateById(staffCustomer);
    }

    /**
     * 删除用户企业对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteStaffCustomerByIds(String ids) {
        String[] idsArray = StrUtil.split(ids,",");
        return staffCustomerMapper.deleteBatchIds(CollUtil.toList(idsArray));
    }

    /**
     * 删除用户企业信息
     * 
     * @param id 用户企业ID
     * @return 结果
     */
    @Override
    public int deleteStaffCustomerById(Long id) {
        return staffCustomerMapper.deleteStaffCustomerById(id);
    }

    @Override
    public List<StaffCustomer> selectStaffCustomerByStaffId(Long id) {
        return staffCustomerMapper.selectStaffCustomerByStaffId(id);

    }

    @Override
    public StaffCustomer selectStaffIdAndCustomerId(Long icsCustomerId, Long staffId) {

        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("staff_id",staffId);
        queryWrapper.eq("ics_customer_id",icsCustomerId);
        return staffCustomerMapper.selectOne(queryWrapper);
    }

    @Override
    public List<StaffCustomer> selectStaffCustomerByStaffIdAndParkId(Long id, String parkId) {

        return staffCustomerMapper.selectStaffCustomerByStaffIdAndParkId(id,parkId);
    }
}
