<?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.huimv.env.admin.mapper.TerminalMapper">

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, device_code, type, status, gateway_id
    </sql>
    <select id="listByLocationId" resultType="com.huimv.env.admin.entity.vo.TerminalPageResult">
        SELECT t.device_code AS 'deviceCode',t.device_name AS 'deviceName',t.type AS 'type',t.status AS 'status',
        g.device_code AS 'gatewayCode',g.device_name AS 'gatewayName',g.type AS 'gatewayType',g.status AS 'gatewayStatus'
        FROM
            `base_pigpen` b LEFT JOIN `gateway` g ON b.id = g.location_id LEFT JOIN `terminal` t ON g.id = t.gateway_id
        WHERE
            b.id = #{locationId}
    </select>

</mapper>
