<?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.goafanti.common.dao.ValueEvaluationMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.ValueEvaluation">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="uid" jdbcType="VARCHAR" property="uid" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="value" jdbcType="BIGINT" property="value" />
    <result column="step" jdbcType="INTEGER" property="step" />
    <result column="log" jdbcType="CHAR" property="log" />
  </resultMap>
  <sql id="Base_Column_List">
    id, uid, create_time, name, value, step, log
  </sql>
  <sql id="Column_List">
    id, uid, create_time, name, value, step
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from value_evaluation
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="selectByPrimaryKeyAndUser" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from value_evaluation
    where id = #{id,jdbcType=BIGINT} and uid = #{uid,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from value_evaluation
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.ValueEvaluation">
    insert into value_evaluation (id, uid, create_time, 
      name, value, step, log
      )
    values (#{id,jdbcType=BIGINT}, #{uid,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{name,jdbcType=VARCHAR}, #{value,jdbcType=BIGINT}, #{step,jdbcType=INTEGER}, #{log,jdbcType=CHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.ValueEvaluation">
    insert into value_evaluation
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="uid != null">
        uid,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="value != null">
        value,
      </if>
      <if test="step != null">
        step,
      </if>
      <if test="log != null">
        log,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="uid != null">
        #{uid,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="value != null">
        #{value,jdbcType=BIGINT},
      </if>
      <if test="step != null">
        #{step,jdbcType=INTEGER},
      </if>
      <if test="log != null">
        #{log,jdbcType=CHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ValueEvaluation">
    update value_evaluation
    <set>
      <if test="uid != null">
        uid = #{uid,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="value != null">
        value = #{value,jdbcType=BIGINT},
      </if>
      <if test="step != null">
        step = #{step,jdbcType=INTEGER},
      </if>
      <if test="log != null">
        log = #{log,jdbcType=CHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.ValueEvaluation">
    update value_evaluation
    set uid = #{uid,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      name = #{name,jdbcType=VARCHAR},
      value = #{value,jdbcType=BIGINT},
      step = #{step,jdbcType=INTEGER},
      log = #{log,jdbcType=CHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="findUserListByPage" resultMap="BaseResultMap">
  	select 
    <include refid="Column_List" />
    from value_evaluation
    where 
    uid = #{uid,jdbcType=VARCHAR}
    <if test="name != null">
      and name = #{name,jdbcType=VARCHAR},
    </if>
    order by id desc 
    <if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
  
  <select id="findUserListCount" resultType="java.lang.Integer">
  	select 
    count(*)
    from value_evaluation
    where 
    uid = #{uid,jdbcType=VARCHAR}
    <if test="name != null">
      and name = #{name,jdbcType=VARCHAR},
    </if>
  </select>
  
  <delete id="deleteRecords" parameterType="java.lang.Long">
    delete from value_evaluation
    where
    id in 
    <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
		#{item,jdbcType=BIGINT}
	</foreach>
    <if test="uid != null">
    	and uid = #{uid,jdbcType=VARCHAR}
    </if>
  </delete>
</mapper>