package com.fs.company.mapper;

import java.util.List;

import com.fs.company.domain.CompanySms;
import com.fs.company.domain.CompanyVoice;
import com.fs.company.vo.CompanySmsListVO;
import com.fs.company.vo.CompanyVoiceListVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 企业通话Mapper接口
 *
 * @author fs
 * @date 2023-02-23
 */
public interface CompanyVoiceMapper
{
    /**
     * 查询企业通话
     *
     * @param voiceId 企业通话ID
     * @return 企业通话
     */
    public CompanyVoice selectCompanyVoiceById(Long voiceId);

    /**
     * 查询企业通话列表
     *
     * @param companyVoice 企业通话
     * @return 企业通话集合
     */
    public List<CompanyVoice> selectCompanyVoiceList(CompanyVoice companyVoice);

    /**
     * 新增企业通话
     *
     * @param companyVoice 企业通话
     * @return 结果
     */
    public int insertCompanyVoice(CompanyVoice companyVoice);

    /**
     * 修改企业通话
     *
     * @param companyVoice 企业通话
     * @return 结果
     */
    public int updateCompanyVoice(CompanyVoice companyVoice);

    /**
     * 删除企业通话
     *
     * @param voiceId 企业通话ID
     * @return 结果
     */
    public int deleteCompanyVoiceById(Long voiceId);

    /**
     * 批量删除企业通话
     *
     * @param voiceIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteCompanyVoiceByIds(Long[] voiceIds);
    @Select({"<script> " +
            "select v.*,c.company_name from company_voice  v left join company c on c.company_id=v.company_id " +
            "where 1=1 " +
            "<if test = 'maps.companyId != null  '> " +
            "and v.company_id = #{maps.companyId}" +
            "</if>" +
            "order by v.voice_id desc " +
            "</script>"})
    public List<CompanyVoiceListVO> selectCompanyVoiceListVO(@Param("maps") CompanyVoice companyVoice);
    @Update("update company_voice set times=times+#{times},total_times=total_times+#{times} where company_id=#{companyId}")
    int updateCompanyVoiceTimes(@Param("companyId") Long companyId,@Param("times")Long times);
    @Select("select * from company_voice where company_id=#{companyId}")
    CompanyVoice selectCompanyVoiceByCompanyId(Long companyId);
    @Update("update company_voice set times=times+#{times} where company_id=#{companyId}")
    int updateCompanyVoiceRemainTimes(@Param("companyId") Long companyId,@Param("times")Long times);
}
