2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-01-04 20cf08efd6f966f53f4dfebafb586b127204415a
dao/src/main/resources/mapper/AirEquipmentMapper.xml
@@ -16,31 +16,42 @@
        mac
    </sql>
    <select id="listAirEquipment" resultType="com.sandu.ximon.dao.bo.AirEquipmentBo">
    <select id="listAirEquipmentId" resultType="java.lang.Long">
        SELECT
           t1.*, t2.pole_id,
           t3.pole_name
        MAX(t1.id) AS air_equipment_id
        FROM
           air_equipment t1
        LEFT JOIN pole_binding t2 ON t1.mac = t2.device_code
        AND t2.device_type = 4
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
      ORDER BY
         t1.id DESC
        air_equipment t1
        <if test="keyword != null and keyword != ''">
            LEFT JOIN pole_binding t2 ON t1.mac = t2.device_code
            AND t2.device_type = 3
            LEFT JOIN pole t3 ON t3.id = t2.pole_id
        </if>
        <where>
            <if test="keyword != null and keyword != ''">
                AND t3.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
            </if>
            <if test="clientId != null">
                AND t3.client_id = #{clientId}
            </if>
        </where>
        GROUP BY
        t1.mac
    </select>
    <select id="listAirEquipmentByKeyword" resultType="com.sandu.ximon.dao.bo.AirEquipmentBo">
        SELECT
           t1.*, t2.pole_id,
           t3.pole_name
        FROM
           air_equipment t1
        LEFT JOIN pole_binding t2 ON t1.mac = t2.device_code
        AND t2.device_type = 4
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        WHERE
          t3.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
      ORDER BY
         t1.id DESC
    <select id="listAirEquipmentByIds" resultType="com.sandu.ximon.dao.bo.AirEquipmentBo">
        SELECT
        t1.*, t2.pole_id,
        t3.pole_name
        FROM
        air_equipment t1
        LEFT JOIN pole_binding t2 ON t1.mac = t2.device_code
        AND t2.device_type = 3
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        <where>
            t1.id IN
            <foreach collection="airEquipmentIdList" open="(" close=")" item="airId" separator=",">
                #{airId}
            </foreach>
        </where>
    </select>
</mapper>