<?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.MusicSceneMapper">
    
    <resultMap type="MusicScene" id="MusicSceneResult">
        <result property="id"    column="id"    />
        <result property="sceneId"    column="scene_id"    />
        <result property="scene"    column="scene"    />
        <result property="musicAddr"    column="music_addr"    />
        <result property="imgAddr"    column="img_addr"    />
        <result property="creator"    column="creator"    />
        <result property="modify"    column="modify"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectMusicSceneVo">
        select id, scene_id, scene, music_addr, creator, modify, create_time, update_time, is_del,img_addr from music_scene
    </sql>

    <select id="selectMusicSceneList" parameterType="MusicScene" resultMap="MusicSceneResult">
        <include refid="selectMusicSceneVo"/>
        <where>  
            <if test="sceneId != null "> and scene_id = #{sceneId}</if>
            <if test="scene != null  and scene != ''"> and scene = #{scene}</if>
            <if test="musicAddr != null  and musicAddr != ''"> and music_addr = #{musicAddr}</if>
            <if test="creator != null  and creator != ''"> and creator = #{creator}</if>
            <if test="modify != null  and modify != ''"> and modify = #{modify}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectMusicSceneById" parameterType="String" resultMap="MusicSceneResult">
        <include refid="selectMusicSceneVo"/>
        where id = #{id}
    </select>

    <insert id="insertMusicScene" parameterType="MusicScene" useGeneratedKeys="true" keyProperty="id">
        insert into music_scene
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sceneId != null">scene_id,</if>
            <if test="scene != null">scene,</if>
            <if test="musicAddr != null">music_addr,</if>
            <if test="creator != null">creator,</if>
            <if test="modify != null">modify,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="imgAddr != null">img_addr,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sceneId != null">#{sceneId},</if>
            <if test="scene != null">#{scene},</if>
            <if test="musicAddr != null">#{musicAddr},</if>
            <if test="creator != null">#{creator},</if>
            <if test="modify != null">#{modify},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="imgAddr != null">#{imgAddr},</if>
         </trim>
    </insert>

    <update id="updateMusicScene" parameterType="MusicScene">
        update music_scene
        <trim prefix="SET" suffixOverrides=",">
            <if test="sceneId != null">scene_id = #{sceneId},</if>
            <if test="scene != null">scene = #{scene},</if>
            <if test="musicAddr != null">music_addr = #{musicAddr},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="modify != null">modify = #{modify},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="imgAddr != null">img_addr = #{imgAddr},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMusicSceneById" parameterType="String">
        delete from music_scene where id = #{id}
    </delete>

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

    <select id="selectMusicSceneBySceneIds" resultMap="MusicSceneResult">
        <include refid="selectMusicSceneVo" /> where scene_id in
        <foreach collection="array" item="sceneId" open="(" separator="," close=")">
            #{sceneId}
        </foreach>
        and is_del=0
    </select>
</mapper>