<?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.securitycontrol.screen.mapper.IVideoMapper">

    <!--视频列表获取-->
    <select id="getVideoTree" resultType="com.securitycontrol.entity.screen.vo.DtreeVo">
        (SELECT '0' AS id,'球机' AS title, '-1' AS parentId,'0' AS onLine,'1' AS level)
    UNION ALL
        (
            SELECT CONCAT('QJ',td.device_code) AS id,
            td.device_name AS title,
            '0' AS parentId,
            on_line AS onLine,
            '2' AS level
            FROM tb_device td
            INNER JOIN t_class_metting tcm on td.device_code = tcm.puid AND tcm.work_day = CURRENT_DATE
            WHERE td.del_flag = 0
            <if test="param!=null and param!=''">
                AND INSTR(td.device_name,#{param}) > 0
            </if>
            <if test="bidCode!=null and bidCode!=''">
                AND INSTR(tcm.bid_code,#{bidCode}) > 0
            </if>
            <if test="bidCode==null or bidCode==''">
                AND tcm.bid_code = '-1'
            </if>
        )
    </select>
</mapper>