<?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.xhpc.tradebill.mapper.XhpcTradebillUploadRecordMapper">
  <resultMap id="BaseResultMap" type="com.xhpc.tradebill.domain.XhpcTradebillUploadRecordDomain">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="source" jdbcType="VARCHAR" property="source" />
    <result column="file_name" jdbcType="VARCHAR" property="fileName" />
    <result column="url" jdbcType="VARCHAR" property="url" />
    <result column="type" jdbcType="SMALLINT" property="type" />
    <result column="status" jdbcType="SMALLINT" property="status" />
    <result column="del_flag" jdbcType="SMALLINT" property="delFlag" />
    <result column="success_count" jdbcType="INTEGER" property="successCount" />
    <result column="fail_count" jdbcType="INTEGER" property="failCount" />
    <result column="uncheck_count" jdbcType="INTEGER" property="uncheckCount" />
    <result column="checked_count" jdbcType="INTEGER" property="checkedCount" />
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  </resultMap>
  <sql id="Base_Column_List">
    id, create_time, create_by, update_time, update_by, `source`, file_name, url, `type`,
    `status`, del_flag, success_count, fail_count, uncheck_count, checked_count, tenant_id
  </sql>


  <select id="selectByUrl" parameterType="java.lang.String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from xhpc_tradebill_upload_record
    where url = #{url,jdbcType=VARCHAR}
  </select>

  <select id="selectByType" resultType="com.xhpc.tradebill.domain.XhpcTradebillUploadRecordDomain">
    select
    <include refid="Base_Column_List" />
    from xhpc_tradebill_upload_record
    <where>
        <if test="params.type != null and params.type!=''">
          and type = #{params.type}
        </if>
        <if test="params.name!=null and params.name!=''">
          and file_name concat('%', #{params.name}, '%')
        </if>
        and create_by=#{params.createBy}
    </where>
    order by update_time desc
  </select>

  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from xhpc_tradebill_upload_record
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from xhpc_tradebill_upload_record
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xhpc.tradebill.domain.XhpcTradebillUploadRecordDomain" useGeneratedKeys="true">
    insert into xhpc_tradebill_upload_record (create_time, create_by, update_time,
                                              update_by, `source`, file_name,
                                              url, `type`, `status`,
                                              del_flag, success_count, fail_count,
                                              uncheck_count, checked_count, tenant_id)
    values (now(), #{createBy,jdbcType=VARCHAR}, now(),
            #{updateBy,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR},
            #{url,jdbcType=VARCHAR}, #{type,jdbcType=SMALLINT}, #{status,jdbcType=SMALLINT},
            #{delFlag,jdbcType=SMALLINT}, #{successCount,jdbcType=INTEGER}, #{failCount,jdbcType=INTEGER},
            #{uncheckCount,jdbcType=INTEGER}, #{checkedCount,jdbcType=INTEGER}, #{tenantId, jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.xhpc.tradebill.domain.XhpcTradebillUploadRecordDomain" useGeneratedKeys="true">
    insert into xhpc_tradebill_upload_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
        create_time,
      <if test="createBy != null">
        create_by,
      </if>
        update_time,
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="source != null">
        `source`,
      </if>
      <if test="fileName != null">
        file_name,
      </if>
      <if test="url != null">
        url,
      </if>
      <if test="type != null">
        `type`,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="delFlag != null">
        del_flag,
      </if>
      <if test="successCount != null">
        success_count,
      </if>
      <if test="failCount != null">
        fail_count,
      </if>
      <if test="uncheckCount != null">
        uncheck_count,
      </if>
      <if test="checkedCount != null">
        checked_count,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      now(),
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
        now(),
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="source != null">
        #{source,jdbcType=VARCHAR},
      </if>
      <if test="fileName != null">
        #{fileName,jdbcType=VARCHAR},
      </if>
      <if test="url != null">
        #{url,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=SMALLINT},
      </if>
      <if test="status != null">
        #{status,jdbcType=SMALLINT},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=SMALLINT},
      </if>
      <if test="successCount != null">
        #{successCount,jdbcType=INTEGER},
      </if>
      <if test="failCount != null">
        #{failCount,jdbcType=INTEGER},
      </if>
      <if test="uncheckCount != null">
        #{uncheckCount,jdbcType=INTEGER},
      </if>
      <if test="checkedCount != null">
        #{checkedCount,jdbcType=INTEGER},
      </if>
        <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
        </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.xhpc.tradebill.domain.XhpcTradebillUploadRecordDomain">
    update xhpc_tradebill_upload_record
    <set>
        update_time = now(),
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="source != null">
        `source` = #{source,jdbcType=VARCHAR},
      </if>
      <if test="fileName != null">
        file_name = #{fileName,jdbcType=VARCHAR},
      </if>
      <if test="url != null">
        url = #{url,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        `type` = #{type,jdbcType=SMALLINT},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=SMALLINT},
      </if>
      <if test="delFlag != null">
        del_flag = #{delFlag,jdbcType=SMALLINT},
      </if>
      <if test="successCount != null">
        success_count = #{successCount,jdbcType=INTEGER},
      </if>
      <if test="failCount != null">
        fail_count = #{failCount,jdbcType=INTEGER},
      </if>
      <if test="uncheckCount != null">
        uncheck_count = #{uncheckCount,jdbcType=INTEGER},
      </if>
      <if test="checkedCount != null">
        checked_count = #{checkedCount,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.xhpc.tradebill.domain.XhpcTradebillUploadRecordDomain">
    update xhpc_tradebill_upload_record
    set update_time = now(),
        update_by = #{updateBy,jdbcType=VARCHAR},
        `source` = #{source,jdbcType=VARCHAR},
        file_name = #{fileName,jdbcType=VARCHAR},
        url = #{url,jdbcType=VARCHAR},
        `type` = #{type,jdbcType=SMALLINT},
        `status` = #{status,jdbcType=SMALLINT},
        del_flag = #{delFlag,jdbcType=SMALLINT},
        success_count = #{successCount,jdbcType=INTEGER},
        fail_count = #{failCount,jdbcType=INTEGER},
        uncheck_count = #{uncheckCount,jdbcType=INTEGER},
        checked_count = #{checkedCount,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>