<?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.business.mapper.HwAlarmTypeMapper">
    
    <resultMap type="HwAlarmType" id="HwAlarmTypeResult">
        <result property="alarmTypeId"    column="alarm_type_id"    />
        <result property="alarmTypeName"    column="alarm_type_name"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="sceneId"    column="scene_id"    />
        <result property="languageCode"    column="language_code"    />
        <result property="commonFlag"    column="common_flag"    />
        <result property="handleMode"    column="handle_mode"    />
        <result property="typeStatus"    column="type_status"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="alarmTypeField"    column="alarm_type_field"    />
    </resultMap>

    <sql id="selectHwAlarmTypeVo">
        select alarm_type_id, alarm_type_name, tenant_id, scene_id, language_code, common_flag, handle_mode, type_status, remark, create_by, create_time, update_by, update_time, alarm_type_field from hw_alarm_type hat
    </sql>

    <select id="selectHwAlarmTypeList" parameterType="HwAlarmType" resultMap="HwAlarmTypeResult">
        <include refid="selectHwAlarmTypeVo"/>
        <where>  
            <if test="alarmTypeName != null  and alarmTypeName != ''"> and alarm_type_name like concat('%', #{alarmTypeName}, '%')</if>
            <if test="tenantId != null "> and tenant_id = #{tenantId}</if>
            <if test="sceneId != null "> and scene_id = #{sceneId}</if>
            <if test="languageCode != null  and languageCode != ''"> and language_code = #{languageCode}</if>
            <if test="commonFlag != null  and commonFlag != ''"> and common_flag = #{commonFlag}</if>
            <if test="handleMode != null  and handleMode != ''"> and handle_mode = #{handleMode}</if>
            <if test="typeStatus != null  and typeStatus != ''"> and type_status = #{typeStatus}</if>
            <if test="alarmTypeField != null  and alarmTypeField != ''"> and alarm_type_field = #{alarmTypeField}</if>
        </where>
    </select>
    
    <select id="selectHwAlarmTypeByAlarmTypeId" parameterType="Long" resultMap="HwAlarmTypeResult">
        <include refid="selectHwAlarmTypeVo"/>
        where alarm_type_id = #{alarmTypeId}
    </select>
        
    <insert id="insertHwAlarmType" parameterType="HwAlarmType" useGeneratedKeys="true" keyProperty="alarmTypeId">
        insert into hw_alarm_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="alarmTypeName != null and alarmTypeName != ''">alarm_type_name,</if>
            <if test="tenantId != null">tenant_id,</if>
            <if test="sceneId != null">scene_id,</if>
            <if test="languageCode != null">language_code,</if>
            <if test="commonFlag != null and commonFlag != ''">common_flag,</if>
            <if test="handleMode != null and handleMode != ''">handle_mode,</if>
            <if test="typeStatus != null and typeStatus != ''">type_status,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="alarmTypeField != null">alarm_type_field,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="alarmTypeName != null and alarmTypeName != ''">#{alarmTypeName},</if>
            <if test="tenantId != null">#{tenantId},</if>
            <if test="sceneId != null">#{sceneId},</if>
            <if test="languageCode != null">#{languageCode},</if>
            <if test="commonFlag != null and commonFlag != ''">#{commonFlag},</if>
            <if test="handleMode != null and handleMode != ''">#{handleMode},</if>
            <if test="typeStatus != null and typeStatus != ''">#{typeStatus},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="alarmTypeField != null">#{alarmTypeField},</if>
         </trim>
    </insert>

    <update id="updateHwAlarmType" parameterType="HwAlarmType">
        update hw_alarm_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="alarmTypeName != null and alarmTypeName != ''">alarm_type_name = #{alarmTypeName},</if>
            <if test="tenantId != null">tenant_id = #{tenantId},</if>
            <if test="sceneId != null">scene_id = #{sceneId},</if>
            <if test="languageCode != null">language_code = #{languageCode},</if>
            <if test="commonFlag != null and commonFlag != ''">common_flag = #{commonFlag},</if>
            <if test="handleMode != null and handleMode != ''">handle_mode = #{handleMode},</if>
            <if test="typeStatus != null and typeStatus != ''">type_status = #{typeStatus},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="alarmTypeField != null">alarm_type_field = #{alarmTypeField},</if>
        </trim>
        where alarm_type_id = #{alarmTypeId}
    </update>

    <delete id="deleteHwAlarmTypeByAlarmTypeId" parameterType="Long">
        delete from hw_alarm_type where alarm_type_id = #{alarmTypeId}
    </delete>

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