<?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.yeejoin.equipmanage.mapper.VideoImportantEquipmentMapper">
    <select id="getVideoImportantEquipmentList"
            resultType="com.yeejoin.equipmanage.common.vo.VideoImportantEquipmentVo" parameterType="java.util.Map">
        SELECT
            v.id AS videoId,
            v.`name`,
            v.`code`,
            v.type_code,
            v.type,
            v.url,
            v.img,
            v.address,
            vie.important_equipment_id
        FROM
            wl_video v
                LEFT JOIN wl_video_important_equipment vie ON v.id = vie.video_id
        <where>
            <if test="importantEquipmentId != null">
                vie.important_equipment_id = #{importantEquipmentId}
            </if>
        </where>
    </select>
    <select id="getVideoList" resultType="com.yeejoin.equipmanage.common.vo.VideoImportantEquipmentVo">
        SELECT
        v.id AS videoId,
        v.`name`,
        v.`code`,
        v.type_code,
        v.type,
        v.url,
        v.img,
        v.address,
        v.video_type as videoType,
        v.token as token
        FROM
        wl_video v
        <where>
            <if test="importantEquipmentId != null">
                v.id in (select video_id from wl_video_important_equipment
                where important_equipment_id = #{importantEquipmentId})
            </if>
        </where>
        ORDER BY v.create_date DESC
    </select>
</mapper>
