<?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.fs.course.mapper.FsUserCourseNoteLikeMapper">
    
    <resultMap type="FsUserCourseNoteLike" id="FsUserCourseNoteLikeResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="noteId"    column="note_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectFsUserCourseNoteLikeVo">
        select id, user_id, note_id, create_time, update_time from fs_user_course_note_like
    </sql>

    <select id="selectFsUserCourseNoteLikeList" parameterType="FsUserCourseNoteLike" resultMap="FsUserCourseNoteLikeResult">
        <include refid="selectFsUserCourseNoteLikeVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="noteId != null "> and note_id = #{noteId}</if>
        </where>
    </select>
    
    <select id="selectFsUserCourseNoteLikeById" parameterType="Long" resultMap="FsUserCourseNoteLikeResult">
        <include refid="selectFsUserCourseNoteLikeVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsUserCourseNoteLike" parameterType="FsUserCourseNoteLike" useGeneratedKeys="true" keyProperty="id">
        insert into fs_user_course_note_like
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="noteId != null">note_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="noteId != null">#{noteId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateFsUserCourseNoteLike" parameterType="FsUserCourseNoteLike">
        update fs_user_course_note_like
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="noteId != null">note_id = #{noteId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsUserCourseNoteLikeById" parameterType="Long">
        delete from fs_user_course_note_like where id = #{id}
    </delete>

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