<?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.MusicRecommendMapper">
    
    <resultMap type="MusicRecommend" id="MusicRecommendResult">
        <result property="id"    column="id"    />
        <result property="recommendId"    column="recommend_id"    />
        <result property="musicId"    column="music_id"    />
    </resultMap>

    <sql id="selectMusicRecommendVo">
        select id, recommend_id, music_id from music_recommend
    </sql>

    <select id="selectMusicRecommendList" parameterType="MusicRecommend" resultMap="MusicRecommendResult">
        <include refid="selectMusicRecommendVo"/>
        <where>  
            <if test="recommendId != null "> and recommend_id = #{recommendId}</if>
            <if test="musicId != null "> and music_id = #{musicId}</if>
        </where>
    </select>
    
    <select id="selectMusicRecommendById" parameterType="String" resultMap="MusicRecommendResult">
        <include refid="selectMusicRecommendVo"/>
        where id = #{id}
    </select>

    <insert id="insertMusicRecommend" parameterType="MusicRecommend" useGeneratedKeys="true" keyProperty="id">
        insert into music_recommend
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="recommendId != null">recommend_id,</if>
            <if test="musicId != null">music_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="recommendId != null">#{recommendId},</if>
            <if test="musicId != null">#{musicId},</if>
         </trim>
    </insert>

    <update id="updateMusicRecommend" parameterType="MusicRecommend">
        update music_recommend
        <trim prefix="SET" suffixOverrides=",">
            <if test="recommendId != null">recommend_id = #{recommendId},</if>
            <if test="musicId != null">music_id = #{musicId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMusicRecommendById" parameterType="String">
        delete from music_recommend where id = #{id}
    </delete>

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