<?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.ExpenseAccountLogMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.ExpenseAccountLog">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="eaid" jdbcType="INTEGER" property="eaid" />
    <result column="process_status" jdbcType="INTEGER" property="processStatus" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
    <result column="auditor" jdbcType="VARCHAR" property="auditor" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, eaid, process_status, `status`, remarks, auditor, create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from expense_account_log
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from expense_account_log
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccountLog" useGeneratedKeys="true">
    insert into expense_account_log (eaid, process_status, `status`,
      remarks, auditor, create_time
      )
    values (#{eaid,jdbcType=INTEGER}, #{processStatus,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
      #{remarks,jdbcType=VARCHAR}, #{auditor,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccountLog" useGeneratedKeys="true">
    insert into expense_account_log
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="eaid != null">
        eaid,
      </if>
      <if test="processStatus != null">
        process_status,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="remarks != null">
        remarks,
      </if>
      <if test="auditor != null">
        auditor,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="eaid != null">
        #{eaid,jdbcType=INTEGER},
      </if>
      <if test="processStatus != null">
        #{processStatus,jdbcType=INTEGER},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="remarks != null">
        #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="auditor != null">
        #{auditor,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ExpenseAccountLog">
    update expense_account_log
    <set>
      <if test="eaid != null">
        eaid = #{eaid,jdbcType=INTEGER},
      </if>
      <if test="processStatus != null">
        process_status = #{processStatus,jdbcType=INTEGER},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=INTEGER},
      </if>
      <if test="remarks != null">
        remarks = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="auditor != null">
        auditor = #{auditor,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.ExpenseAccountLog">
    update expense_account_log
    set eaid = #{eaid,jdbcType=INTEGER},
      process_status = #{processStatus,jdbcType=INTEGER},
      `status` = #{status,jdbcType=INTEGER},
      remarks = #{remarks,jdbcType=VARCHAR},
      auditor = #{auditor,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectByEaid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountLog">
    select a.id,a.eaid ,a.status ,a.remarks ,a.auditor ,b.name auditorName,a.process_status processStatus,
           date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr
    from expense_account_log a left join admin b on a.auditor =b.id
    where a.eaid= #{eaid}
    order by a.create_time
  </select>

</mapper>
