package com.fs.qw.mapper;

import com.fs.qw.domain.FsAppContactWay;
import com.fs.qw.vo.FsAppContactWayListVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * app客服活码上架Mapper接口
 *
 * @author fs
 * @date 2024-12-02
 */
public interface FsAppContactWayMapper
{
    /**
     * 查询app客服活码上架
     *
     * @param id app客服活码上架主键
     * @return app客服活码上架
     */
    public FsAppContactWay selectFsAppContactWayById(Long id);

    /**
     * 查询app客服活码上架列表
     *
     * @param fsAppContactWay app客服活码上架
     * @return app客服活码上架集合
     */
    public List<FsAppContactWay> selectFsAppContactWayList(FsAppContactWay fsAppContactWay);

    /**
     * 新增app客服活码上架
     *
     * @param fsAppContactWay app客服活码上架
     * @return 结果
     */
    public int insertFsAppContactWay(FsAppContactWay fsAppContactWay);

    /**
     * 修改app客服活码上架
     *
     * @param fsAppContactWay app客服活码上架
     * @return 结果
     */
    public int updateFsAppContactWay(FsAppContactWay fsAppContactWay);

    /**
     * 删除app客服活码上架
     *
     * @param id app客服活码上架主键
     * @return 结果
     */
    public int deleteFsAppContactWayById(Long id);

    /**
     * 批量删除app客服活码上架
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsAppContactWayByIds(Long[] ids);
    @Select({"<script> " +
            "select f.*,c.company_name from fs_app_contact_way f  " +
            "left join company c on c.company_id = f.company_id " +
            "where 1=1 " +
            "<if test = ' maps.companyId !=null '> " +
            "and f.company_id = #{maps.companyId} " +
            "</if>" +
            " order by f.id desc  "+
            "</script>"})
    List<FsAppContactWayListVO> selectFsAppContactWayListVO(@Param("maps") FsAppContactWay fsAppContactWay);

    @Select("select * from fs_app_contact_way where status = 1 order by RAND() limit 1")
    FsAppContactWay selectContactWayRandom();
}
