<?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.DeviceStructureMapper">


    <select id="getAllDeviceStructure" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.DeviceStructure">
        select * from device_structure a
    </select>

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

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

        </where>
    </select>

    <select id="getDeviceStructureByCode" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.DeviceStructure">
        select * from device_structure 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>

</mapper>
