<?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.yunfeiyun.agmp.fms.mapper.FmsCalarmMapper">
    
    <resultMap type="FmsCalarm" id="FmsCalarmResult">
        <result property="calarmId"    column="calarmId"    />
        <result property="calarmType"    column="calarmType"    />
        <result property="calarmName"    column="calarmName"    />
        <result property="calarmCloudresurl"    column="calarmCloudresurl"    />
        <result property="calarmCreateddate"    column="calarmCreateddate"    />
        <result property="calarmCreator"    column="calarmCreator"    />
        <result property="calamRemark"    column="calamRemark"    />
    </resultMap>

    <sql id="selectFmsCalarmVo">
        select calarmId, calarmType, calarmName, calarmCloudresurl, calarmCreateddate, calarmCreator, calamRemark from FmsCalarm
    </sql>

    <select id="selectFmsCalarmList" parameterType="FmsCalarm" resultMap="FmsCalarmResult">
        <include refid="selectFmsCalarmVo"/>
        <where>  
            <if test="calarmType != null  and calarmType != ''"> and calarmType = #{calarmType}</if>
            <if test="calarmName != null  and calarmName != ''"> and calarmName like concat('%', #{calarmName}, '%')</if>
            <if test="calarmCloudresurl != null  and calarmCloudresurl != ''"> and calarmCloudresurl = #{calarmCloudresurl}</if>
            <if test="calarmCreateddate != null  and calarmCreateddate != ''"> and calarmCreateddate = #{calarmCreateddate}</if>
            <if test="calarmCreator != null  and calarmCreator != ''"> and calarmCreator = #{calarmCreator}</if>
            <if test="calamRemark != null  and calamRemark != ''"> and calamRemark = #{calamRemark}</if>
        </where>
    </select>
    
    <select id="selectFmsCalarmByCalarmId" parameterType="String" resultMap="FmsCalarmResult">
        <include refid="selectFmsCalarmVo"/>
        where calarmId = #{calarmId}
    </select>
        
    <insert id="insertFmsCalarm" parameterType="FmsCalarm">
        insert into FmsCalarm
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="calarmId != null">calarmId,</if>
            <if test="calarmType != null">calarmType,</if>
            <if test="calarmName != null">calarmName,</if>
            <if test="calarmCloudresurl != null">calarmCloudresurl,</if>
            <if test="calarmCreateddate != null">calarmCreateddate,</if>
            <if test="calarmCreator != null">calarmCreator,</if>
            <if test="calamRemark != null">calamRemark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="calarmId != null">#{calarmId},</if>
            <if test="calarmType != null">#{calarmType},</if>
            <if test="calarmName != null">#{calarmName},</if>
            <if test="calarmCloudresurl != null">#{calarmCloudresurl},</if>
            <if test="calarmCreateddate != null">#{calarmCreateddate},</if>
            <if test="calarmCreator != null">#{calarmCreator},</if>
            <if test="calamRemark != null">#{calamRemark},</if>
         </trim>
    </insert>

    <update id="updateFmsCalarm" parameterType="FmsCalarm">
        update FmsCalarm
        <trim prefix="SET" suffixOverrides=",">
            <if test="calarmType != null">calarmType = #{calarmType},</if>
            <if test="calarmName != null">calarmName = #{calarmName},</if>
            <if test="calarmCloudresurl != null">calarmCloudresurl = #{calarmCloudresurl},</if>
            <if test="calarmCreateddate != null">calarmCreateddate = #{calarmCreateddate},</if>
            <if test="calarmCreator != null">calarmCreator = #{calarmCreator},</if>
            <if test="calamRemark != null">calamRemark = #{calamRemark},</if>
        </trim>
        where calarmId = #{calarmId}
    </update>

    <delete id="deleteFmsCalarmByCalarmId" parameterType="String">
        delete from FmsCalarm where calarmId = #{calarmId}
    </delete>

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