<?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.boco.nbd.wios.manage.mapper.def.OperateLogMapper">
  
<resultMap id="BaseResultMap" type="com.boco.nbd.wios.manage.entity.bo.OperateLog">
  <id column="id" jdbcType="INTEGER" property="id" />
  <result column="type" jdbcType="INTEGER" property="type" />
  <result column="third_party_id" jdbcType="VARCHAR" property="thirdPartyId" />
  <result column="pre_name" jdbcType="VARCHAR" property="preName" />
  <result column="pre_value" jdbcType="VARCHAR" property="preValue" />
  <result column="name" jdbcType="VARCHAR" property="name" />
  <result column="value" jdbcType="VARCHAR" property="value" />
  <result column="desc" jdbcType="VARCHAR" property="desc" />
  <result column="create_account" jdbcType="INTEGER" property="createAccount" />
  <result column="create_account_name" jdbcType="VARCHAR" property="createAccountName" />
  <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>

  
<sql id="Base_Column_List">
  id, type, third_party_id, pre_name, pre_value, name, value, `desc`, create_account,
  create_account_name, create_time
</sql>

  
<delete id="delete" parameterType="java.lang.Integer">
  delete from t_operate_log
  where id = #{id,jdbcType=INTEGER}
</delete>
  <delete id="deleteByOrderId">
    delete from t_operate_log
    where third_party_id = #{orderId}
  </delete>


  <insert id="insert" parameterType="com.boco.nbd.wios.manage.entity.bo.OperateLog">
  insert into t_operate_log (id, type, third_party_id, 
    pre_name, pre_value, name, 
    value, `desc`, create_account, 
    create_account_name, create_time)
  values (#{id,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, #{thirdPartyId,jdbcType=VARCHAR}, 
    #{preName,jdbcType=VARCHAR}, #{preValue,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 
    #{value,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{createAccount,jdbcType=INTEGER}, 
    #{createAccountName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})
</insert>

  
<insert id="insertDynamic" parameterType="com.boco.nbd.wios.manage.entity.bo.OperateLog">
  insert into t_operate_log
  <trim prefix="(" suffix=")" suffixOverrides=",">
    <if test="id != null">
      id,
    </if>
    <if test="type != null">
      type,
    </if>
    <if test="thirdPartyId != null">
      third_party_id,
    </if>
    <if test="preName != null">
      pre_name,
    </if>
    <if test="preValue != null">
      pre_value,
    </if>
    <if test="name != null">
      name,
    </if>
    <if test="value != null">
      value,
    </if>
    <if test="desc != null">
      desc,
    </if>
    <if test="createAccount != null">
      create_account,
    </if>
    <if test="createAccountName != null">
      create_account_name,
    </if>
    <if test="createTime != null">
      create_time,
    </if>
  </trim>
  <trim prefix="values (" suffix=")" suffixOverrides=",">
    <if test="id != null">
      #{id,jdbcType=INTEGER},
    </if>
    <if test="type != null">
      #{type,jdbcType=INTEGER},
    </if>
    <if test="thirdPartyId != null">
      #{thirdPartyId,jdbcType=VARCHAR},
    </if>
    <if test="preName != null">
      #{preName,jdbcType=VARCHAR},
    </if>
    <if test="preValue != null">
      #{preValue,jdbcType=VARCHAR},
    </if>
    <if test="name != null">
      #{name,jdbcType=VARCHAR},
    </if>
    <if test="value != null">
      #{value,jdbcType=VARCHAR},
    </if>
    <if test="desc != null">
      #{desc,jdbcType=VARCHAR},
    </if>
    <if test="createAccount != null">
      #{createAccount,jdbcType=INTEGER},
    </if>
    <if test="createAccountName != null">
      #{createAccountName,jdbcType=VARCHAR},
    </if>
    <if test="createTime != null">
      #{createTime,jdbcType=TIMESTAMP},
    </if>
  </trim>
</insert>

  
<update id="updateDynamic" parameterType="com.boco.nbd.wios.manage.entity.bo.OperateLog">
  update t_operate_log
  <set>
    <if test="type != null">
      type = #{type,jdbcType=INTEGER},
    </if>
    <if test="thirdPartyId != null">
      third_party_id = #{thirdPartyId,jdbcType=VARCHAR},
    </if>
    <if test="preName != null">
      pre_name = #{preName,jdbcType=VARCHAR},
    </if>
    <if test="preValue != null">
      pre_value = #{preValue,jdbcType=VARCHAR},
    </if>
    <if test="name != null">
      name = #{name,jdbcType=VARCHAR},
    </if>
    <if test="value != null">
      value = #{value,jdbcType=VARCHAR},
    </if>
    <if test="desc != null">
      desc = #{desc,jdbcType=VARCHAR},
    </if>
    <if test="createAccount != null">
      create_account = #{createAccount,jdbcType=INTEGER},
    </if>
    <if test="createAccountName != null">
      create_account_name = #{createAccountName,jdbcType=VARCHAR},
    </if>
    <if test="createTime != null">
      create_time = #{createTime,jdbcType=TIMESTAMP},
    </if>
  </set>
  where id = #{id,jdbcType=INTEGER}
</update>

  
<update id="update" parameterType="com.boco.nbd.wios.manage.entity.bo.OperateLog">
  update t_operate_log
  set type = #{type,jdbcType=INTEGER},
    third_party_id = #{thirdPartyId,jdbcType=VARCHAR},
    pre_name = #{preName,jdbcType=VARCHAR},
    pre_value = #{preValue,jdbcType=VARCHAR},
    name = #{name,jdbcType=VARCHAR},
    value = #{value,jdbcType=VARCHAR},
    desc = #{desc,jdbcType=VARCHAR},
    create_account = #{createAccount,jdbcType=INTEGER},
    create_account_name = #{createAccountName,jdbcType=VARCHAR},
    create_time = #{createTime,jdbcType=TIMESTAMP}
  where id = #{id,jdbcType=INTEGER}
</update>

  
<select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  select
	<include refid="Base_Column_List" />
  from  t_operate_log
  where id = #{id,jdbcType=INTEGER}
</select>

<select id="selectByExample" parameterType="com.boco.nbd.wios.manage.entity.bo.OperateLogBo"
        resultType="com.boco.nbd.wios.manage.entity.bo.OperateLog">
   select t.* from t_operate_log t
   <where>
	    <if test="type != null">
	        and t.type = #{type}
	    </if>
	    <if test="typeList != null">
	        and t.type in
		   <foreach collection="typeList" item="item" index="index" open="(" close=")" separator=",">
				#{item}
			</foreach>
	    </if>
	    <if test="thirdPartyId != null and thirdPartyId != ''">
	        and t.third_party_id = #{thirdPartyId}
	    </if>
       <if test="name != null and name !='' ">
         and t.name = #{name}
       </if>
   </where>
   order by t.create_time desc
</select>
  <select id="getNewestCheckFailByOrderId" resultType="com.boco.nbd.wios.manage.entity.bo.OperateLog">
    select
    <include refid="Base_Column_List" />
    from  t_operate_log
    where  type=1
        <if test="orderId != null and orderId != ''">
              and third_party_id =#{orderId}
        </if>
        <if test="name != null and name != ''">
          and name=#{name}
        </if>
    ORDER BY
    create_time DESC
    LIMIT 0,1
  </select>

</mapper>