<?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.mmc.iuav.user.dao.BackUserSuggestionDao">

    <resultMap id="BaseResultMap" type="com.mmc.iuav.user.entity.BackUserSuggestionDO">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="title" column="title" jdbcType="VARCHAR"/>
            <result property="coverUrl" column="cover_url" jdbcType="VARCHAR"/>
            <result property="suggestFile" column="suggest_file" jdbcType="VARCHAR"/>
            <result property="backUserId" column="back_user_id" jdbcType="INTEGER"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,create_time,update_time,
        title,cover_url,suggest_file,
        back_user_id
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from back_user_suggestion
        where  back_user_id = #{backUserId,jdbcType=INTEGER}
    </select>
    <select id="countSelectSuggestion" resultType="java.lang.Integer">
        select count(1)
        from back_user_suggestion
        where back_user_id = #{backUserId}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from back_user_suggestion
        where  id = #{id,jdbcType=INTEGER} 
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.mmc.iuav.user.entity.BackUserSuggestionDO" useGeneratedKeys="true">
        insert into back_user_suggestion
        ( id
        ,title,cover_url,suggest_file
        ,back_user_id)
        values (#{id,jdbcType=INTEGER}
        ,#{title,jdbcType=VARCHAR},#{coverUrl,jdbcType=VARCHAR},#{suggestFile,jdbcType=VARCHAR}
        ,#{backUserId,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.mmc.iuav.user.entity.BackUserSuggestionDO" useGeneratedKeys="true">
        insert into back_user_suggestion
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="title != null">title,</if>
                <if test="coverUrl != null">cover_url,</if>
                <if test="suggestFile != null">suggest_file,</if>
                <if test="backUserId != null">back_user_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=INTEGER},</if>
                <if test="title != null">#{title,jdbcType=VARCHAR},</if>
                <if test="coverUrl != null">#{coverUrl,jdbcType=VARCHAR},</if>
                <if test="suggestFile != null">#{suggestFile,jdbcType=VARCHAR},</if>
                <if test="backUserId != null">#{backUserId,jdbcType=INTEGER},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.mmc.iuav.user.entity.BackUserSuggestionDO">
        update back_user_suggestion
        <set>
                    update_time = NOW(),
                <if test="title != null">
                    title = #{title},
                </if>
                <if test="coverUrl != null">
                    cover_url = #{coverUrl},
                </if>
                <if test="suggestFile != null">
                    suggest_file = #{suggestFile},
                </if>
                <if test="backUserId != null">
                    back_user_id = #{backUserId},
                </if>
        </set>
        where   id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.mmc.iuav.user.entity.BackUserSuggestionDO">
        update back_user_suggestion
        set 
            create_time =  #{createTime,jdbcType=TIMESTAMP},
            update_time =  #{updateTime,jdbcType=TIMESTAMP},
            title =  #{title,jdbcType=VARCHAR},
            cover_url =  #{coverUrl,jdbcType=VARCHAR},
            suggest_file =  #{suggestFile,jdbcType=VARCHAR},
            back_user_id =  #{backUserId,jdbcType=INTEGER}
        where   id = #{id,jdbcType=INTEGER} 
    </update>
</mapper>
