<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bcxin.identify.business.dao.ImRoammsgTempMapper">

    <!-- 批量插入im对应条件查询到的聊天记录 by zxf 2021/11/22 -->
    <insert id="batchInsertImRoammsgTemp" parameterType="java.util.List">
        INSERT INTO im_roammsg_temp(
            oid,
            fromAccount,
            toAccount,
            textMsg,
            content,
            pcNo
        ) VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.oid},
            #{item.fromAccount},
            #{item.toAccount},
            #{item.textMsg},
            #{item.content},
            #{item.pcNo}
            )
        </foreach>
    </insert>

    <sql id="findImRoammsgTempByPcNoWhere">
        select
        oid,
        fromAccount,
        toAccount,
        textMsg,
        content,
        pcNo
        FROM im_roammsg_temp
        WHERE pcNo = #{pcNo}
        AND fromAccount = #{fromAccount}
        AND toAccount = #{toAccount}
        AND instr(textMsg,#{keyword})
    </sql>

    <select id="findImRoammsgTempByPcNo" resultType="com.bcxin.identify.business.domain.ImRoammsgTemp">
        <include refid="findImRoammsgTempByPcNoWhere"/>
    </select>

    <delete id="deleteByExpire" >
        DELETE
          FROM im_roammsg_temp
         WHERE (#{times}-1800) <![CDATA[ > ]]> pcNo
  </delete>
</mapper>