<?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.huijy.management.mapper.EarlyWarningSendLogMapper">

    <resultMap type="EarlyWarningSendLog" id="EarlyWarningSendLogResult">
        <result property="sendLogId"    column="send_log_id"    />
        <result property="earlyWarningId"    column="early_warning_id"    />
        <result property="mpOpenId"    column="mp_open_id"    />
        <result property="sendCode"    column="send_code"    />
        <result property="sendTime"    column="send_time"    />
        <result property="msgId"    column="msg_id"    />
    </resultMap>

    <sql id="selectEarlyWarningSendLogVo">
        select send_log_id, early_warning_id, mp_open_id, send_code, send_time, msg_id from t_early_warning_send_log
    </sql>

    <select id="selectEarlyWarningSendLogList" parameterType="EarlyWarningSendLog" resultMap="EarlyWarningSendLogResult">
        <include refid="selectEarlyWarningSendLogVo"/>
        <where>
            <if test="sendCode != null  and sendCode != ''"> and send_code = #{sendCode}</if>
        </where>
    </select>

    <select id="selectEarlyWarningSendLogBySendLogId" parameterType="Long" resultMap="EarlyWarningSendLogResult">
        <include refid="selectEarlyWarningSendLogVo"/>
        where send_log_id = #{sendLogId}
    </select>

    <insert id="insertEarlyWarningSendLog" parameterType="EarlyWarningSendLog" useGeneratedKeys="true" keyProperty="sendLogId">
        insert into t_early_warning_send_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="earlyWarningId != null">early_warning_id,</if>
            <if test="mpOpenId != null">mp_open_id,</if>
            <if test="sendCode != null">send_code,</if>
            <if test="sendTime != null">send_time,</if>
            <if test="msgId != null">msg_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="earlyWarningId != null">#{earlyWarningId},</if>
            <if test="mpOpenId != null">#{mpOpenId},</if>
            <if test="sendCode != null">#{sendCode},</if>
            <if test="sendTime != null">#{sendTime},</if>
            <if test="msgId != null">#{msgId},</if>
         </trim>
    </insert>

    <update id="updateEarlyWarningSendLog" parameterType="EarlyWarningSendLog">
        update t_early_warning_send_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="earlyWarningId != null">early_warning_id = #{earlyWarningId},</if>
            <if test="mpOpenId != null">mp_open_id = #{mpOpenId},</if>
            <if test="sendCode != null">send_code = #{sendCode},</if>
            <if test="sendTime != null">send_time = #{sendTime},</if>
            <if test="msgId != null">msg_id = #{msgId},</if>
        </trim>
        where send_log_id = #{sendLogId}
    </update>

    <delete id="deleteEarlyWarningSendLogBySendLogId" parameterType="Long">
        delete from t_early_warning_send_log where send_log_id = #{sendLogId}
    </delete>

    <delete id="deleteEarlyWarningSendLogBySendLogIds" parameterType="String">
        delete from t_early_warning_send_log where send_log_id in
        <foreach item="sendLogId" collection="array" open="(" separator="," close=")">
            #{sendLogId}
        </foreach>
    </delete>

    <update id="updateLogByMsgId" parameterType="Long">
        update t_early_warning_send_log set send_code = #{sendCode} where msg_id=#{msgId}
    </update>
</mapper>
