<?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.AmbInvestLogMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.AmbInvestLog">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="amb_invest_id" jdbcType="BIGINT" property="ambInvestId" />
    <result column="amount" jdbcType="DECIMAL" property="amount" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="comment" jdbcType="VARCHAR" property="comment" />
    <result column="operator" jdbcType="VARCHAR" property="operator" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, amb_invest_id, amount, `status`, `comment`, `operator`, create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from amb_invest_log
    where id = #{id,jdbcType=BIGINT}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from amb_invest_log
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.AmbInvestLog" useGeneratedKeys="true">
    insert into amb_invest_log (amb_invest_id, amount, `status`,
      `comment`, `operator`, create_time
      )
    values (#{ambInvestId,jdbcType=BIGINT}, #{amount,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER},
      #{comment,jdbcType=VARCHAR}, #{operator,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.AmbInvestLog" useGeneratedKeys="true">
    insert into amb_invest_log
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="ambInvestId != null">
        amb_invest_id,
      </if>
      <if test="amount != null">
        amount,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="comment != null">
        `comment`,
      </if>
      <if test="operator != null">
        `operator`,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="ambInvestId != null">
        #{ambInvestId,jdbcType=BIGINT},
      </if>
      <if test="amount != null">
        #{amount,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="comment != null">
        #{comment,jdbcType=VARCHAR},
      </if>
      <if test="operator != null">
        #{operator,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.AmbInvestLog">
    update amb_invest_log
    <set>
      <if test="ambInvestId != null">
        amb_invest_id = #{ambInvestId,jdbcType=BIGINT},
      </if>
      <if test="amount != null">
        amount = #{amount,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=INTEGER},
      </if>
      <if test="comment != null">
        `comment` = #{comment,jdbcType=VARCHAR},
      </if>
      <if test="operator != null">
        `operator` = #{operator,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.AmbInvestLog">
    update amb_invest_log
    set amb_invest_id = #{ambInvestId,jdbcType=BIGINT},
      amount = #{amount,jdbcType=DECIMAL},
      `status` = #{status,jdbcType=INTEGER},
      `comment` = #{comment,jdbcType=VARCHAR},
      `operator` = #{operator,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <select id="selectByAmbInvestId" resultType="com.goafanti.ambSystem.bo.OutInvestLog">
    select a.id ,a.amb_invest_id ambInvestId ,a.status ,a.comment ,b.name operator,
           date_format(a.create_time,'%Y-%m-%d %H:%i:%S') createTimes
    from amb_invest_log a  left join admin b on a.operator =b.id
    where amb_invest_id = #{id}
  </select>
</mapper>
