package com.fs.qw.mapper;

import com.fs.qw.domain.QwAppContactWayLogs;
import com.fs.qw.param.QwAppContactWayLogsParam;
import com.fs.qw.vo.QwAppContactWayLogsListVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 联系我日志Mapper接口
 *
 * @author fs
 * @date 2024-12-11
 */
public interface QwAppContactWayLogsMapper
{
    /**
     * 查询联系我日志
     *
     * @param id 联系我日志主键
     * @return 联系我日志
     */
    public QwAppContactWayLogs selectQwAppContactWayLogsById(Long id);

    /**
     * 查询联系我日志列表
     *
     * @param qwAppContactWayLogs 联系我日志
     * @return 联系我日志集合
     */
    public List<QwAppContactWayLogs> selectQwAppContactWayLogsList(QwAppContactWayLogs qwAppContactWayLogs);

    /**
     * 新增联系我日志
     *
     * @param qwAppContactWayLogs 联系我日志
     * @return 结果
     */
    public int insertQwAppContactWayLogs(QwAppContactWayLogs qwAppContactWayLogs);
    public int insertOrUpdateQwAppContactWayLogs(QwAppContactWayLogs qwAppContactWayLogs);

    /**
     * 修改联系我日志
     *
     * @param qwAppContactWayLogs 联系我日志
     * @return 结果
     */
    public int updateQwAppContactWayLogs(QwAppContactWayLogs qwAppContactWayLogs);

    /**
     * 删除联系我日志
     *
     * @param id 联系我日志主键
     * @return 结果
     */
    public int deleteQwAppContactWayLogsById(Long id);

    /**
     * 批量删除联系我日志
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteQwAppContactWayLogsByIds(Long[] ids);

    QwAppContactWayLogs selectQwAppContactWayLogsByAppWayId(Long id);
    @Select({"<script>  " +
            "select l.*,qu.qw_user_name,c.company_name,cu.nick_name,qc.corp_name from qw_app_contact_way_logs l LEFT JOIN qw_user qu on qu.id=l.qw_user_id LEFT JOIN company c on l.company_id=c.company_id LEFT JOIN company_user cu ON cu.user_id =l.company_user_id LEFT JOIN qw_company qc on  qc.corp_id=l.corp_id" +
            " where 1=1   "+
            "   <if test=\"appWayId != null \"> and l.app_way_id = #{appWayId}</if>\n" +
            "   <if test=\"source != null  and source != ''\"> and l.source = #{source}</if>\n" +
            "   <if test=\"userId != null \"> and l.user_id = #{userId}</if>\n" +
            "   <if test=\"companyId != null \"> and l.company_id = #{companyId}</if>\n" +
            "   <if test=\"companyUserId != null \"> and l.company_user_id = #{companyUserId}</if>\n" +
            "   <if test=\"corpId != null  and corpId != ''\"> and l.corp_id = #{corpId}</if>\n" +
            "   <if test=\"externalUserId != null \"> and l.external_user_id = #{externalUserId}</if>"+
            "   <if test=\"sTime != null \">  and DATE(l.create_time) &gt;= DATE(#{sTime})</if>\n" +
            "   <if test=\"eTime != null \">  and DATE(l.create_time) &lt;= DATE(#{eTime})</if>\n" +
            " order by id desc "+
            "</script>"})
    List<QwAppContactWayLogsListVO> selectQwAppContactWayLogsListVO(QwAppContactWayLogsParam qwAppContactWayLogs);
}
