<?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.ruoyi.rocketmq.mapper.RmAlarmPushConfigMapper">
    
    <resultMap type="RmAlarmPushConfig" id="RmAlarmPushConfigResult">
        <result property="id"    column="id"    />
        <result property="configName"    column="config_name"    />
        <result property="pushMethod"    column="push_method"    />
        <result property="pushAddress"    column="push_address"    />
        <result property="pushAlarmTypes"    column="push_alarm_types"    />
        <result property="messageContent"    column="message_content"    />
        <result property="contactPhones"    column="contact_phones"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectRmAlarmPushConfigVo">
        select id, config_name, push_method, push_address, push_alarm_types, message_content, contact_phones, create_time, update_time, create_by, update_by from rm_alarm_push_config
    </sql>

    <select id="selectRmAlarmPushConfigList" parameterType="RmAlarmPushConfig" resultMap="RmAlarmPushConfigResult">
        <include refid="selectRmAlarmPushConfigVo"/>
        <where>  
            <if test="configName != null  and configName != ''"> and config_name like concat('%', #{configName}, '%')</if>
            <if test="pushMethod != null  and pushMethod != ''"> and push_method = #{pushMethod}</if>
            <if test="pushAddress != null  and pushAddress != ''"> and push_address = #{pushAddress}</if>
            <if test="pushAlarmTypes != null  and pushAlarmTypes != ''"> and push_alarm_types = #{pushAlarmTypes}</if>
            <if test="messageContent != null  and messageContent != ''"> and message_content = #{messageContent}</if>
            <if test="contactPhones != null  and contactPhones != ''"> and contact_phones = #{contactPhones}</if>
        </where>
    </select>
    
    <select id="selectRmAlarmPushConfigById" parameterType="Long" resultMap="RmAlarmPushConfigResult">
        <include refid="selectRmAlarmPushConfigVo"/>
        where id = #{id}
    </select>

    <insert id="insertRmAlarmPushConfig" parameterType="RmAlarmPushConfig" useGeneratedKeys="true" keyProperty="id">
        insert into rm_alarm_push_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="configName != null and configName != ''">config_name,</if>
            <if test="pushMethod != null and pushMethod != ''">push_method,</if>
            <if test="pushAddress != null and pushAddress != ''">push_address,</if>
            <if test="pushAlarmTypes != null">push_alarm_types,</if>
            <if test="messageContent != null">message_content,</if>
            <if test="contactPhones != null">contact_phones,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="configName != null and configName != ''">#{configName},</if>
            <if test="pushMethod != null and pushMethod != ''">#{pushMethod},</if>
            <if test="pushAddress != null and pushAddress != ''">#{pushAddress},</if>
            <if test="pushAlarmTypes != null">#{pushAlarmTypes},</if>
            <if test="messageContent != null">#{messageContent},</if>
            <if test="contactPhones != null">#{contactPhones},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateRmAlarmPushConfig" parameterType="RmAlarmPushConfig">
        update rm_alarm_push_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="configName != null and configName != ''">config_name = #{configName},</if>
            <if test="pushMethod != null and pushMethod != ''">push_method = #{pushMethod},</if>
            <if test="pushAddress != null and pushAddress != ''">push_address = #{pushAddress},</if>
            <if test="pushAlarmTypes != null">push_alarm_types = #{pushAlarmTypes},</if>
            <if test="messageContent != null">message_content = #{messageContent},</if>
            <if test="contactPhones != null">contact_phones = #{contactPhones},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRmAlarmPushConfigById" parameterType="Long">
        delete from rm_alarm_push_config where id = #{id}
    </delete>

    <delete id="deleteRmAlarmPushConfigByIds" parameterType="String">
        delete from rm_alarm_push_config where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>