package com.fs.company.mapper;

import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fs.company.domain.CompanyVoiceRoboticBusiness;
import com.fs.company.domain.CompanyVoiceRoboticCallees;
import org.apache.ibatis.annotations.Param;

/**
 * ai外呼业务Mapper接口
 * 
 * @author fs
 * @date 2026-01-30
 */
public interface CompanyVoiceRoboticBusinessMapper extends BaseMapper<CompanyVoiceRoboticBusiness>{
    /**
     * 查询ai外呼业务
     * 
     * @param id ai外呼业务主键
     * @return ai外呼业务
     */
    CompanyVoiceRoboticBusiness selectCompanyVoiceRoboticBusinessById(Long id);

    /**
     * 查询ai外呼业务列表
     * 
     * @param companyVoiceRoboticBusiness ai外呼业务
     * @return ai外呼业务集合
     */
    List<CompanyVoiceRoboticBusiness> selectCompanyVoiceRoboticBusinessList(CompanyVoiceRoboticBusiness companyVoiceRoboticBusiness);

    /**
     * 新增ai外呼业务
     * 
     * @param companyVoiceRoboticBusiness ai外呼业务
     * @return 结果
     */
    int insertCompanyVoiceRoboticBusiness(CompanyVoiceRoboticBusiness companyVoiceRoboticBusiness);

    /**
     * 修改ai外呼业务
     * 
     * @param companyVoiceRoboticBusiness ai外呼业务
     * @return 结果
     */
    int updateCompanyVoiceRoboticBusiness(CompanyVoiceRoboticBusiness companyVoiceRoboticBusiness);

    /**
     * 删除ai外呼业务
     * 
     * @param id ai外呼业务主键
     * @return 结果
     */
    int deleteCompanyVoiceRoboticBusinessById(Long id);

    /**
     * 批量删除ai外呼业务
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteCompanyVoiceRoboticBusinessByIds(Long[] ids);

    /**
     * 批量插入业务数据
     * @param businessList 业务数据列表
     * @return 影响的行数
     */
    int insertBatch(@Param("list") List<CompanyVoiceRoboticBusiness> businessList);

    /**
     * 更新业务动作调用次数
     * @param actionType 1、addWx; 2、callPhone; 3、sendMsg
     * @param roboticId
     * @param callerId
     * @param wxClientId
     * @return
     */
    int updateActionCount(@Param("actionType") Integer actionType,
                          @Param("roboticId") Long roboticId,
                          @Param("callerId") Long callerId,
                          @Param("wxClientId") Long wxClientId);

    CompanyVoiceRoboticBusiness selectCompanyVoiceRoboticBusinessByWorkflowInstanceId(String workflowInstanceId);

    CompanyVoiceRoboticCallees selectCalleesByBusinessId(@Param("businessId") Long businessId);

    Integer selectUnfinishedTaskCountByRoboticId(@Param("roboticId") Long roboticId, @Param("endNodeKey") String endNodeKey);

    /**
     * 批量插入生成业务数据
     * @param businessList 业务数据列表
     * @return 影响的行数
     */
    int insertBatchGenerateInfo(@Param("list") List<CompanyVoiceRoboticBusiness> businessList);
}
