<?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.playlet.system.mapper.PlayletAdviceFeedbackMapper">

    <resultMap type="PlayletAdviceFeedback" id="PlayletAdviceFeedbackResult">
        <result property="id"    column="ID"    />
        <result property="userId"    column="USER_ID"    />
        <result property="type"    column="TYPE"    />
        <result property="content"    column="CONTENT"    />
        <result property="url"    column="URL"    />
        <result property="createBy"    column="CREATE_BY"    />
        <result property="createTime"    column="CREATE_TIME"    />
        <result property="updateBy"    column="UPDATE_BY"    />
        <result property="updateTime"    column="UPDATE_TIME"    />
        <result property="remark"    column="REMARK"    />
    </resultMap>

    <sql id="selectPlayletAdviceFeedbackVo">
        select ID, USER_ID, TYPE, CONTENT, URL, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK from playlet_advice_feedback
    </sql>

    <select id="selectPlayletAdviceFeedbackList" parameterType="PlayletAdviceFeedback" resultMap="PlayletAdviceFeedbackResult">
        <include refid="selectPlayletAdviceFeedbackVo"/>
        <where>
            <if test="userId != null "> and USER_ID = #{userId}</if>
            <if test="type != null  and type != ''"> and TYPE = #{type}</if>
            <if test="content != null  and content != ''"> and CONTENT = #{content}</if>
            <if test="url != null  and url != ''"> and URL = #{url}</if>
            <if test="createBy != null  and createBy != ''"> and CREATE_BY = #{createBy}</if>
            <if test="createTime != null "> and CREATE_TIME = #{createTime}</if>
            <if test="updateBy != null  and updateBy != ''"> and UPDATE_BY = #{updateBy}</if>
            <if test="updateTime != null "> and UPDATE_TIME = #{updateTime}</if>
            <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
        </where>
    </select>

    <select id="selectPlayletAdviceFeedbackById" parameterType="Long" resultMap="PlayletAdviceFeedbackResult">
        <include refid="selectPlayletAdviceFeedbackVo"/>
        where ID = #{id}
    </select>

    <insert id="insertPlayletAdviceFeedback" parameterType="PlayletAdviceFeedback" useGeneratedKeys="true" keyProperty="id">
        insert into playlet_advice_feedback
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">USER_ID,</if>
            <if test="type != null">TYPE,</if>
            <if test="content != null">CONTENT,</if>
            <if test="url != null">URL,</if>
            <if test="createBy != null">CREATE_BY,</if>
            <if test="createTime != null">CREATE_TIME,</if>
            <if test="updateBy != null">UPDATE_BY,</if>
            <if test="updateTime != null">UPDATE_TIME,</if>
            <if test="remark != null">REMARK,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="type != null">#{type},</if>
            <if test="content != null">#{content},</if>
            <if test="url != null">#{url},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updatePlayletAdviceFeedback" parameterType="PlayletAdviceFeedback">
        update playlet_advice_feedback
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">USER_ID = #{userId},</if>
            <if test="type != null">TYPE = #{type},</if>
            <if test="content != null">CONTENT = #{content},</if>
            <if test="url != null">URL = #{url},</if>
            <if test="createBy != null">CREATE_BY = #{createBy},</if>
            <if test="createTime != null">CREATE_TIME = #{createTime},</if>
            <if test="updateBy != null">UPDATE_BY = #{updateBy},</if>
            <if test="updateTime != null">UPDATE_TIME = #{updateTime},</if>
            <if test="remark != null">REMARK = #{remark},</if>
        </trim>
        where ID = #{id}
    </update>

    <delete id="deletePlayletAdviceFeedbackById" parameterType="Long">
        delete from playlet_advice_feedback where ID = #{id}
    </delete>

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

</mapper>