package com.fs.company.mapper;

import java.util.List;
import com.fs.company.domain.CompanyVoiceMobile;
import com.fs.company.vo.CompanyVoiceMobileVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 中间号Mapper接口
 * 
 * @author fs
 * @date 2021-10-04
 */
public interface CompanyVoiceMobileMapper 
{
    /**
     * 查询中间号
     * 
     * @param mobileId 中间号ID
     * @return 中间号
     */
    public CompanyVoiceMobile selectCompanyVoiceMobileById(Long mobileId);

    /**
     * 查询中间号列表
     * 
     * @param companyVoiceMobile 中间号
     * @return 中间号集合
     */
    public List<CompanyVoiceMobile> selectCompanyVoiceMobileList(CompanyVoiceMobile companyVoiceMobile);

    /**
     * 新增中间号
     * 
     * @param companyVoiceMobile 中间号
     * @return 结果
     */
    public int insertCompanyVoiceMobile(CompanyVoiceMobile companyVoiceMobile);

    /**
     * 修改中间号
     * 
     * @param companyVoiceMobile 中间号
     * @return 结果
     */
    public int updateCompanyVoiceMobile(CompanyVoiceMobile companyVoiceMobile);

    /**
     * 删除中间号
     * 
     * @param mobileId 中间号ID
     * @return 结果
     */
    public int deleteCompanyVoiceMobileById(Long mobileId);

    /**
     * 批量删除中间号
     * 
     * @param mobileIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteCompanyVoiceMobileByIds(Long[] mobileIds);
    @Select({"<script> " +
            "select m.*,a.api_name,c.company_name " +
            "from company_voice_mobile m left join company_voice_api a  on a.api_id=m.api_id left join company c  on c.company_id=m.company_id  " +
            "where 1=1 " +
            "<if test = 'maps.mobile != null and maps.mobile != \"\" '> " +
            "and m.mobile like '%${maps.mobile}%'" +
            "</if>" +
            "<if test = 'maps.apiId != null  '> " +
            "and m.api_id = #{maps.apiId}" +
            "</if>" +
            "<if test = 'maps.mobileType != null  '> " +
            "and m.mobile_type = #{maps.mobileType}" +
            "</if>" +
            "<if test = 'maps.status != null   '> " +
            "and m.status = #{maps.status}" +
            "</if>" +
            "<if test = 'maps.companyId != null   '> " +
            "and m.company_id = #{maps.companyId}" +
            "</if>" +
            "order by m.mobile_id desc " +
            "</script>"})
    List<CompanyVoiceMobileVO> selectCompanyVoiceMobileVOList(@Param("maps")CompanyVoiceMobile companyVoiceMobile);

    @Select("select * from company_voice_mobile where ((company_id=#{companyId} and mobile_type=2) or (mobile_type=1)) and api_id=#{apiId} and status=1 limit 1")
    CompanyVoiceMobile selectEmptyCompanyVoiceMobile(@Param("companyId") Long companyId,@Param("apiId")Long apiId);
    @Select("select count(1) from company_voice_mobile ")
    Integer selectCompanyVoiceMobileCount();
    @Select("select * from company_voice_mobile where mobile=#{mobile} ")
    CompanyVoiceMobile selectCompanyVoiceMobileByMobile(String mobile);
}
