<?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.ruoyi.system.mapper.VideoDataMapper">
    
    <resultMap type="VideoData" id="VideoDataResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="url"    column="url"    />
    </resultMap>

    <sql id="selectVideoDataVo">
        select id, name, url from video_data
    </sql>

    <select id="selectVideoDataList" parameterType="VideoData" resultMap="VideoDataResult">
        <include refid="selectVideoDataVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
        </where>
    </select>
    
    <select id="selectVideoDataById" parameterType="Long" resultMap="VideoDataResult">
        <include refid="selectVideoDataVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertVideoData" parameterType="VideoData" useGeneratedKeys="true" keyProperty="id">
        insert into video_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="url != null and url != ''">url,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="url != null and url != ''">#{url},</if>
         </trim>
    </insert>

    <update id="updateVideoData" parameterType="VideoData">
        update video_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="url != null and url != ''">url = #{url},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteVideoDataById" parameterType="Long">
        delete from video_data where id = #{id}
    </delete>

    <delete id="deleteVideoDataByIds" parameterType="String">
        delete from video_data where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>