<?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.srs.system.mapper.SysSuggestionMapper">
    
    <resultMap type="SysSuggestion" id="SysSuggestionResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="img"    column="img"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectSysSuggestionVo">
        select id, title, img, remark, create_by, create_time from sys_suggestion
    </sql>

    <select id="selectSysSuggestionList" parameterType="SysSuggestion" resultMap="SysSuggestionResult">
        <include refid="selectSysSuggestionVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
        </where>
    </select>
    
    <select id="selectSysSuggestionById" parameterType="Long" resultMap="SysSuggestionResult">
        <include refid="selectSysSuggestionVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysSuggestion" parameterType="SysSuggestion" useGeneratedKeys="true" keyProperty="id">
        insert into sys_suggestion
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="img != null">img,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="img != null">#{img},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateSysSuggestion" parameterType="SysSuggestion">
        update sys_suggestion
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="img != null">img = #{img},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysSuggestionById" parameterType="Long">
        delete from sys_suggestion where id = #{id}
    </delete>

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