<?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.MusicSceneRelateMapper">
    
    <resultMap type="MusicSceneRelate" id="MusicSceneRelateResult">
        <result property="id"    column="id"    />
        <result property="musicId"    column="music_id"    />
        <result property="sceneId"    column="scene_id"    />
    </resultMap>

    <sql id="selectMusicSceneRelateVo">
        select id, music_id, scene_id from music_scene_relate
    </sql>

    <select id="selectMusicSceneRelateList" parameterType="MusicSceneRelate" resultMap="MusicSceneRelateResult">
        <include refid="selectMusicSceneRelateVo"/>
        <where>  
            <if test="musicId != null "> and music_id = #{musicId}</if>
            <if test="sceneId != null "> and scene_id = #{sceneId}</if>
        </where>
    </select>
    
    <select id="selectMusicSceneRelateById" parameterType="String" resultMap="MusicSceneRelateResult">
        <include refid="selectMusicSceneRelateVo"/>
        where id = #{id}
    </select>

    <insert id="insertMusicSceneRelate" parameterType="MusicSceneRelate" useGeneratedKeys="true" keyProperty="id">
        insert into music_scene_relate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="musicId != null">music_id,</if>
            <if test="sceneId != null">scene_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="musicId != null">#{musicId},</if>
            <if test="sceneId != null">#{sceneId},</if>
         </trim>
    </insert>

    <update id="updateMusicSceneRelate" parameterType="MusicSceneRelate">
        update music_scene_relate
        <trim prefix="SET" suffixOverrides=",">
            <if test="musicId != null">music_id = #{musicId},</if>
            <if test="sceneId != null">scene_id = #{sceneId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMusicSceneRelateById" parameterType="String">
        delete from music_scene_relate where id = #{id}
    </delete>

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