<?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.zksy.base.mapper.AlarmAssignDetailMapper">
    
    <resultMap type="com.zksy.base.domain.AlarmAssignDetail" id="AlarmAssignDetailResult">
        <result property="alarmAssignDetailId"    column="alarm_assign_detail_id"    />
        <result property="alarmAssignId"    column="alarm_assign_id"    />
        <result property="handleUserId"    column="handle_user_id"    />
        <result property="handleUserName"    column="handle_user_name"    />
        <result property="handlePhone"    column="handle_phone"    />
        <result property="handleDeptName"    column="handle_dept_name"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectAlarmAssignDetailVo">
        select alarm_assign_detail_id, alarm_assign_id, handle_user_id, handle_user_name, handle_phone, handle_dept_name, remark from alarm_assign_detail
    </sql>

    <select id="selectAlarmAssignDetailList" parameterType="com.zksy.base.domain.AlarmAssignDetail" resultMap="AlarmAssignDetailResult">
        <include refid="selectAlarmAssignDetailVo"/>
        <where>  
            <if test="alarmAssignDetailId != null "> and alarm_assign_detail_id = #{alarmAssignDetailId}</if>
            <if test="alarmAssignId != null "> and alarm_assign_id = #{alarmAssignId}</if>
        </where>
    </select>
    
    <select id="selectAlarmAssignDetailByAlarmAssignDetailId" parameterType="Long" resultMap="AlarmAssignDetailResult">
        <include refid="selectAlarmAssignDetailVo"/>
        where alarm_assign_detail_id = #{alarmAssignDetailId}
    </select>

    <insert id="insertAlarmAssignDetail" parameterType="com.zksy.base.domain.AlarmAssignDetail">
        insert into alarm_assign_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="alarmAssignDetailId != null">alarm_assign_detail_id,</if>
            <if test="alarmAssignId != null">alarm_assign_id,</if>
            <if test="handleUserId != null">handle_user_id,</if>
            <if test="handleUserName != null">handle_user_name,</if>
            <if test="handlePhone != null">handle_phone,</if>
            <if test="handleDeptName != null">handle_dept_name,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="alarmAssignDetailId != null">#{alarmAssignDetailId},</if>
            <if test="alarmAssignId != null">#{alarmAssignId},</if>
            <if test="handleUserId != null">#{handleUserId},</if>
            <if test="handleUserName != null">#{handleUserName},</if>
            <if test="handlePhone != null">#{handlePhone},</if>
            <if test="handleDeptName != null">#{handleDeptName},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateAlarmAssignDetail" parameterType="com.zksy.base.domain.AlarmAssignDetail">
        update alarm_assign_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="alarmAssignId != null">alarm_assign_id = #{alarmAssignId},</if>
            <if test="handleUserId != null">handle_user_id = #{handleUserId},</if>
            <if test="handleUserName != null">handle_user_name = #{handleUserName},</if>
            <if test="handlePhone != null">handle_phone = #{handlePhone},</if>
            <if test="handleDeptName != null">handle_dept_name = #{handleDeptName},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where alarm_assign_detail_id = #{alarmAssignDetailId}
    </update>

    <delete id="deleteAlarmAssignDetailByAlarmAssignDetailId" parameterType="Long">
        delete from alarm_assign_detail where alarm_assign_detail_id = #{alarmAssignDetailId}
    </delete>

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