package com.gyee.alarm.mapper.auto;

import com.gyee.alarm.model.auto.ProBasicDeviceStructure;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 设备结构 Mapper 接口
 * </p>
 *
 * @author shilin
 * @since 2023-08-01
 */
public interface ProBasicDeviceStructureMapper extends BaseMapper<ProBasicDeviceStructure> {

    @Select({"<script>",
            "select * from pro_basic_device_structure a ",
            "<where>",
            "<if test='deviceId !=null' >",
            "and a.device_id=#{deviceId}",
            "</if>",
            "<if test='nodeCode !=null '>",
            "and a.code=#{nodeCode}",
            "</if>",
            "</where>",

            "</script>"})
    ProBasicDeviceStructure getDeviceStructureByCode(@Param("deviceId")String deviceId,
                                             @Param("nodeCode")String nodeCode);

    @Select({"<script>",
            "select * from pro_basic_device_structure a ",
            "<where>",
            "<if test='deviceId !=null' >",
            "and a.device_id=#{deviceId}",
            "</if>",

            "</where>",

            "</script>"})
    List<ProBasicDeviceStructure> getDeviceStructureByDeviceId(@Param("deviceId")String deviceId);
    @Select({"<script>",
            "select * from pro_basic_device_structure a ",
            "<where>",
            "<if test='deviceId !=null' >",
            "and a.device_id=#{deviceId}",
            "</if>",
            "<if test='nodeCode !=null '>",
            "and a.parent_code=#{nodeCode}",
            "</if>",
            "</where>",

            "</script>"})
    List<ProBasicDeviceStructure> getDeviceStructureChildNode(@Param("deviceId")String deviceId,
                                                      @Param("nodeCode")String nodeCode);
}
