<?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.izouma.awesomeadmin.dao.FeedbackMapper">
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.Feedback">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
        <result column="user_id" property="userId" jdbcType="INTEGER"/>
        <result column="user_name" property="userName" jdbcType="VARCHAR"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
        <result column="image" property="image" jdbcType="VARCHAR"/>
        <result column="telephone" property="telephone" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">
            id,            del_flag,            user_id,            user_name,            remark,            image,            telephone,            create_time,            update_time        </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from feedback
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from feedback
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.Feedback" useGeneratedKeys="true"
            keyProperty="id">
        insert into feedback
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!= null">
                id,
            </if>
            <if test="delFlag!= null">
                del_flag,
            </if>
            <if test="userId!= null">
                user_id,
            </if>
            <if test="userName!= null">
                user_name,
            </if>
            <if test="remark!= null">
                remark,
            </if>
            <if test="image!= null">
                image,
            </if>
            <if test="telephone!= null">
                telephone,
            </if>
            <if test="createTime!= null">
                create_time,
            </if>
            <if test="updateTime!= null">
                update_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=CHAR},
            </if>
            <if test="userId != null">
                #{userId,jdbcType=INTEGER},
            </if>
            <if test="userName != null">
                #{userName,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                #{remark,jdbcType=VARCHAR},
            </if>
            <if test="image != null">
                #{image,jdbcType=VARCHAR},
            </if>
            <if test="telephone != null">
                #{telephone,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.Feedback">
        update feedback
        <set>
            <if test="id != null">
                id= #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                del_flag= #{delFlag,jdbcType=CHAR},
            </if>
            <if test="userId != null">
                user_id= #{userId,jdbcType=INTEGER},
            </if>
            <if test="userName != null">
                user_name= #{userName,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                remark= #{remark,jdbcType=VARCHAR},
            </if>
            <if test="image != null">
                image= #{image,jdbcType=VARCHAR},
            </if>
            <if test="telephone != null">
                telephone= #{telephone,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time= #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time= #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="queryFeedbackByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.Feedback">
        select
        <include refid="Base_Column_List"/>
        from feedback
        <where>
            and del_flag = 'N'
            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                and id = #{record.id}
            </if>
            <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
                and del_flag = #{record.delFlag}
            </if>
            <if test="record.userId != null and !&quot;&quot;.equals(record.userId)">
                and user_id = #{record.userId}
            </if>
            <if test="record.userName != null and !&quot;&quot;.equals(record.userName)">
                and user_name = #{record.userName}
            </if>
            <if test="record.remark != null and !&quot;&quot;.equals(record.remark)">
                and remark = #{record.remark}
            </if>
            <if test="record.image != null and !&quot;&quot;.equals(record.image)">
                and image = #{record.image}
            </if>
            <if test="record.telephone != null and !&quot;&quot;.equals(record.telephone)">
                and telephone = #{record.telephone}
            </if>
            <if test="record.createTime != null and !&quot;&quot;.equals(record.createTime)">
                and create_time = #{record.createTime}
            </if>
            <if test="record.updateTime != null and !&quot;&quot;.equals(record.updateTime)">
                and update_time = #{record.updateTime}
            </if>

            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR user_id LIKE concat('%',#{record.searchKey},'%')
                    OR user_name LIKE concat('%',#{record.searchKey},'%')
                    OR remark LIKE concat('%',#{record.searchKey},'%')
                </trim>
            </if>

        </where>
        order by id desc
    </select>
    <select id="queryAllFeedback" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.Feedback">
        select
        <include refid="Base_Column_List"/>
        from feedback
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="userId != null and !&quot;&quot;.equals(userId)">
                and user_id = #{userId}
            </if>
            <if test="userName != null and !&quot;&quot;.equals(userName)">
                and user_name = #{userName}
            </if>
            <if test="remark != null and !&quot;&quot;.equals(remark)">
                and remark = #{remark}
            </if>
            <if test="image != null and !&quot;&quot;.equals(image)">
                and image = #{image}
            </if>
            <if test="telephone != null and !&quot;&quot;.equals(telephone)">
                and telephone = #{telephone}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
        </where>
        order by id desc
    </select>
    <select id="queryFeedback" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.Feedback">
        select
        <include refid="Base_Column_List"/>
        from feedback
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="userId != null and !&quot;&quot;.equals(userId)">
                and user_id = #{userId}
            </if>
            <if test="userName != null and !&quot;&quot;.equals(userName)">
                and user_name = #{userName}
            </if>
            <if test="remark != null and !&quot;&quot;.equals(remark)">
                and remark = #{remark}
            </if>
            <if test="image != null and !&quot;&quot;.equals(image)">
                and image = #{image}
            </if>
            <if test="telephone != null and !&quot;&quot;.equals(telephone)">
                and telephone = #{telephone}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>

        </where>
        LIMIT 1
    </select>
    <update id="delete">
        UPDATE feedback SET del_flag = 'Y'
        <where>
            AND id = #{id}
        </where>
    </update>
    <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.Feedback">
        select
        <include refid="Base_Column_List"/>
        from feedback
        <where>
            and del_flag = 'N'
        </where>
        order by id desc
    </select>
</mapper>

