<?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.railway.business.app.mapper.AppFeedbackMapper">

  <resultMap id="BaseResultMap" type="com.railway.business.app.domain.AppFeedback">
    <result column="id" property="id"/>
    <result column="user_id" property="userId"/>
    <result column="content" property="content"/>
    <result column="del_flag" property="delFlag"/>
    <result column="create_by" property="createBy"/>
    <result column="create_time" property="createTime"/>
    <result column="update_by" property="updateBy"/>
    <result column="update_time" property="updateTime"/>
  </resultMap>

  <sql id="Base_Column_List">
    id,
    user_id,
    content,
    del_flag,
    create_by,
    create_time,
    update_by,
    update_time
  </sql>

  <insert id="insert" parameterType="com.railway.business.app.domain.AppFeedback">
    <selectKey keyProperty="id" order="BEFORE" resultType="String">
      select replace(uuid(), '-', '') from dual
    </selectKey>
    INSERT INTO app_feedback
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test='null != userId'>
        user_id,
      </if>
      <if test='null != content'>
        content,
      </if>
      <if test='null != delFlag'>
        del_flag,
      </if>
      <if test='null != createBy'>
        create_by,
      </if>
      <if test='null != createTime'>
        create_time,
      </if>
      <if test='null != updateBy'>
        update_by,
      </if>
      <if test='null != updateTime'>
        update_time
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test='null != userId'>
        #{userId},
      </if>
      <if test='null != content'>
        #{content},
      </if>
      <if test='null != delFlag'>
        #{delFlag},
      </if>
      <if test='null != createBy'>
        #{createBy},
      </if>
      <if test='null != createTime'>
        #{createTime},
      </if>
      <if test='null != updateBy'>
        #{updateBy},
      </if>
      <if test='null != updateTime'>
        #{updateTime}
      </if>
    </trim>
  </insert>

  <delete id="delete">
    UPDATE app_feedback
    set del_flag='1'
    WHERE id = #{id}
  </delete>

  <update id="update" parameterType="com.railway.business.app.domain.AppFeedback">
    UPDATE app_feedback
    <set>
      <if test='null != userId'>user_id = #{userId},</if>
      <if test='null != content'>content = #{content},</if>
      <if test='null != delFlag'>del_flag = #{delFlag},</if>
      <if test='null != createBy'>create_by = #{createBy},</if>
      <if test='null != createTime'>create_time = #{createTime},</if>
      <if test='null != updateBy'>update_by = #{updateBy},</if>
      <if test='null != updateTime'>update_time = #{updateTime}</if>
    </set>
    WHERE id = #{id}
  </update>


  <select id="getInfo" resultMap="BaseResultMap">
    SELECT
    <include refid="Base_Column_List"/>
    FROM app_feedback
    WHERE del_flag='0' and id = #{id}

  </select>

  <select id="getList" resultMap="BaseResultMap">
    SELECT
    <include refid="Base_Column_List"/>
    FROM app_feedback
    <where>
      del_flag='0'
      <if test="userId!=null and userId!=''">
        and user_id=#{userId}
      </if>
      <if test="content!=null and content!=''">
        and content=#{content}
      </if>
      <if test="delFlag!=null and delFlag!=''">
        and del_flag=#{delFlag}
      </if>
      <if test="createBy!=null and createBy!=''">
        and create_by=#{createBy}
      </if>
      <if test="createTime!=null and createTime!=''">
        and create_time=#{createTime}
      </if>
      <if test="updateBy!=null and updateBy!=''">
        and update_by=#{updateBy}
      </if>
      <if test="updateTime!=null and updateTime!=''">
        and update_time=#{updateTime}
      </if>
    </where>
  </select>

</mapper>