<?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.gyee.wisdom.alarm.sharding.mapper.DeviceFaultModeMapper">

    <select id="getDeviceFaultModeByDeviceId" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.DeviceFaultMode">
        select * from device_fault_mode a
        <where>
            1=1
            <if test="deviceId !=null and deviceId !=''">
                and a.deviceId=#{deviceId}
            </if>
        </where>
    </select>

    <select id="getDeviceFaultModeByStructureCode" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.DeviceFaultMode">
        select * from device_fault_mode a
        <where>
            1=1
            <if test="deviceId !=null and deviceId !=''">
                and a.deviceId=#{deviceId}
                <if test="structureCode !=null and structureCode !=''">
                    and a.structurecode like '${structureCode}%'
                </if>
            </if>

        </where>
    </select>

    <select id="getDeviceFaultModeByCode" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.DeviceFaultMode">
        select * from device_fault_mode a
        <where>
            1=1
            <if test="code !=null and code !=''">
                    and a.code=#{code}
            </if>
        </where>
    </select>

    <select id="getDeviceFaultModeTree" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.DeviceFaultMode">
        select * from device_fault_mode a
        <where>
            1=1
            <if test="deviceId !=null and deviceId !=''">
                and a.deviceId=#{deviceId}
                <if test="nodeCode !=null and nodeCode !=''">
                    and a.code=#{nodeCode}
                </if>
            </if>

        </where>
    </select>

    <delete id="deleteDeviceFaultMode" parameterType="Long">
        delete from device_fault_mode where id = #{id}
    </delete>
</mapper>
