<?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.bonus.sgzb.app.mapper.LeaseApplyInfoMapper">
  <resultMap id="BaseResultMap" type="com.bonus.sgzb.app.domain.LeaseApplyInfo">
    <!--@mbg.generated-->
    <!--@Table lease_apply_info-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="task_id" jdbcType="INTEGER" property="taskId" />
    <result column="lease_person" jdbcType="VARCHAR" property="leasePerson" />
    <result column="phone" jdbcType="VARCHAR" property="phone" />
    <result column="type" jdbcType="VARCHAR" property="type" />
    <result column="company_audit_by" jdbcType="INTEGER" property="companyAuditBy" />
    <result column="company_audit_time" jdbcType="VARCHAR" property="companyAuditTime" />
    <result column="company_audit_remark" jdbcType="VARCHAR" property="companyAuditRemark" />
    <result column="dept_audit_by" jdbcType="INTEGER" property="deptAuditBy" />
    <result column="dept_audit_time" jdbcType="VARCHAR" property="deptAuditTime" />
    <result column="dept_audit_remark" jdbcType="VARCHAR" property="deptAuditRemark" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="company_id" jdbcType="INTEGER" property="companyId" />
  </resultMap>

  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, code, task_id, lease_person, phone, `type`, company_audit_by, company_audit_time, company_audit_remark,
    dept_audit_by, dept_audit_time, dept_audit_remark, create_by, create_time, update_by, 
    update_time, remark, company_id
  </sql>

  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from lease_apply_info
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectByTaskIdAndCompId" resultType="com.bonus.sgzb.app.domain.LeaseApplyInfo">
      select *
      from lease_apply_info
      where task_id = #{taskId}
      and company_id = #{companyId}
  </select>
  <select id="selectByTaskIdAndCompIdCq" resultType="com.bonus.sgzb.app.domain.LeaseApplyInfo">
    SELECT
      *
    FROM
      lease_apply_info
    WHERE
      task_id = #{taskId}
      AND company_id IS NULL
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--@mbg.generated-->
    delete from lease_apply_info
    where id = #{id,jdbcType=INTEGER}
  </delete>

  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.app.domain.LeaseApplyInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into lease_apply_info (code, task_id, lease_person, phone,
    `type`, company_audit_by, company_audit_time,
    company_audit_remark, dept_audit_by, dept_audit_time,
    dept_audit_remark, create_by, create_time,
    update_by, update_time, remark,
    company_id,estimate_lease_time,lease_type,cost_bearing_party)
    values (#{code,jdbcType=VARCHAR}, #{taskId,jdbcType=INTEGER}, #{leasePerson,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
    #{type,jdbcType=VARCHAR}, #{companyAuditBy,jdbcType=INTEGER}, #{companyAuditTime,jdbcType=VARCHAR},
    #{companyAuditRemark,jdbcType=VARCHAR}, #{deptAuditBy,jdbcType=INTEGER}, #{deptAuditTime,jdbcType=VARCHAR},
    #{deptAuditRemark,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, NOW(),
    #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR},
    #{companyId,jdbcType=INTEGER}, #{estimateLeaseTime,jdbcType=TIMESTAMP},#{leaseType,jdbcType=VARCHAR},#{costBearingParty,jdbcType=VARCHAR})
  </insert>

  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.app.domain.LeaseApplyInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into lease_apply_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="taskId != null">
        task_id,
      </if>
      <if test="leasePerson != null and leasePerson != ''">
        lease_person,
      </if>
      <if test="phone != null and phone != ''">
        phone,
      </if>
      <if test="type != null and type != ''">
        `type`,
      </if>
      <if test="companyAuditBy != null">
        company_audit_by,
      </if>
      <if test="companyAuditTime != null">
        company_audit_time,
      </if>
      <if test="companyAuditRemark != null and companyAuditRemark != ''">
        company_audit_remark,
      </if>
      <if test="deptAuditBy != null">
        dept_audit_by,
      </if>
      <if test="deptAuditTime != null">
        dept_audit_time,
      </if>
      <if test="deptAuditRemark != null and deptAuditRemark != ''">
        dept_audit_remark,
      </if>
      <if test="createBy != null and createBy != ''">
        create_by,
      </if>
      create_time,
      <if test="updateBy != null and updateBy != ''">
        update_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="remark != null and remark != ''">
        remark,
      </if>
      <if test="companyId != null">
        company_id,
      </if>
      <if test="leaseType != null and leaseType != ''">
        lease_type,
      </if>
      <if test="estimateLeaseTime != null">
        estimate_lease_time,
      </if>
      <if test="costBearingParty != null and costBearingParty != ''">
        cost_bearing_party,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="taskId != null">
        #{taskId,jdbcType=INTEGER},
      </if>
      <if test="leasePerson != null and leasePerson != ''">
        #{leasePerson,jdbcType=VARCHAR},
      </if>
      <if test="phone != null and phone != ''">
        #{phone,jdbcType=VARCHAR},
      </if>
      <if test="type != null and type != ''">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="companyAuditBy != null">
        #{companyAuditBy,jdbcType=INTEGER},
      </if>
      <if test="companyAuditTime != null">
        #{companyAuditTime},
      </if>
      <if test="companyAuditRemark != null and companyAuditRemark != ''">
        #{companyAuditRemark,jdbcType=VARCHAR},
      </if>
      <if test="deptAuditBy != null">
        #{deptAuditBy,jdbcType=INTEGER},
      </if>
      <if test="deptAuditTime != null">
        #{deptAuditTime},
      </if>
      <if test="deptAuditRemark != null and deptAuditRemark != ''">
        #{deptAuditRemark,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null and createBy != ''">
        #{createBy,jdbcType=VARCHAR},
      </if>
        NOW(),
      <if test="updateBy != null and updateBy != ''">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null and remark != ''">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=INTEGER},
      </if>
      <if test="leaseType != null and leaseType != ''">
        #{leaseType,jdbcType=VARCHAR},
      </if>
      <if test="estimateLeaseTime != null">
        #{estimateLeaseTime,jdbcType=TIMESTAMP},
      </if>
      <if test="costBearingParty != null and costBearingParty != ''">
        #{costBearingParty,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <update id="updateByPrimaryKeySelective" parameterType="com.bonus.sgzb.app.domain.LeaseApplyInfo">
    <!--@mbg.generated-->
    update lease_apply_info
    <set>
      <if test="taskId != null">
        task_id = #{taskId,jdbcType=INTEGER},
      </if>
      <if test="leasePerson != null and leasePerson != ''">
        lease_person = #{leasePerson,jdbcType=VARCHAR},
      </if>
      <if test="phone != null and phone != ''">
        phone = #{phone,jdbcType=VARCHAR},
      </if>
      <if test="type != null and type != ''">
        `type` = #{type,jdbcType=VARCHAR},
      </if>
      <if test="companyAuditBy != null">
        company_audit_by = #{companyAuditBy,jdbcType=INTEGER},
      </if>
      <if test="companyAuditTime != null and companyAuditTime != ''">
        company_audit_time = #{companyAuditTime,jdbcType=VARCHAR},
      </if>
      <if test="companyAuditRemark != null and companyAuditRemark != ''">
        company_audit_remark = #{companyAuditRemark,jdbcType=VARCHAR},
      </if>
      <if test="deptAuditBy != null">
        dept_audit_by = #{deptAuditBy,jdbcType=INTEGER},
      </if>
      <if test="deptAuditTime != null and deptAuditTime != ''">
        dept_audit_time = #{deptAuditTime,jdbcType=VARCHAR},
      </if>
      <if test="deptAuditRemark != null and deptAuditRemark != ''">
        dept_audit_remark = #{deptAuditRemark,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null and createBy != ''">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null and updateBy != ''">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="remark != null and remark != ''">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="companyId != null">
        company_id = #{companyId,jdbcType=INTEGER},
      </if>
      update_time = NOW(),
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>

  <update id="updateByPrimaryKey" parameterType="com.bonus.sgzb.app.domain.LeaseApplyInfo">
    <!--@mbg.generated-->
    update lease_apply_info
    set task_id = #{taskId,jdbcType=INTEGER},
      lease_person = #{leasePerson,jdbcType=VARCHAR},
      phone = #{phone,jdbcType=VARCHAR},
      `type` = #{type,jdbcType=VARCHAR},
      company_audit_by = #{companyAuditBy,jdbcType=INTEGER},
      company_audit_time = #{companyAuditTime,jdbcType=VARCHAR},
      company_audit_remark = #{companyAuditRemark,jdbcType=VARCHAR},
      dept_audit_by = #{deptAuditBy,jdbcType=INTEGER},
      dept_audit_time = #{deptAuditTime,jdbcType=VARCHAR},
      dept_audit_remark = #{deptAuditRemark,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=VARCHAR},
      update_time = NOW(),
      remark = #{remark,jdbcType=VARCHAR},
      company_id = #{companyId,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update lease_apply_info
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="task_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.taskId,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="lease_person = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.leasePerson,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="phone = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.phone,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="`type` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.type,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="company_audit_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.companyAuditBy,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="company_audit_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.companyAuditTime,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="company_audit_remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.companyAuditRemark,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="dept_audit_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.deptAuditBy,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="dept_audit_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.deptAuditTime,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="dept_audit_remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.deptAuditRemark,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="create_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.createBy,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="create_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="update_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.updateBy,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="update_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.updateTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.remark,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="company_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.companyId,jdbcType=INTEGER}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=INTEGER}
    </foreach>
  </update>

  <update id="updateBatchSelective" parameterType="java.util.List">
    <!--@mbg.generated-->
    update lease_apply_info
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="task_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.taskId != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.taskId,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="lease_person = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.leasePerson != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.leasePerson,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="phone = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.phone != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.phone,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="`type` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.type != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.type,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="company_audit_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.companyAuditBy != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.companyAuditBy,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="company_audit_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.companyAuditTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.companyAuditTime,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="company_audit_remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.companyAuditRemark != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.companyAuditRemark,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="dept_audit_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.deptAuditBy != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.deptAuditBy,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="dept_audit_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.deptAuditTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.deptAuditTime,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="dept_audit_remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.deptAuditRemark != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.deptAuditRemark,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="create_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createBy != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.createBy,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="create_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="update_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updateBy != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.updateBy,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="update_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updateTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.updateTime,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.remark != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.remark,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="company_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.companyId != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.companyId,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=INTEGER}
    </foreach>
  </update>

  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into lease_apply_info
    (task_id, lease_person, phone, `type`, company_audit_by, company_audit_time, company_audit_remark, 
      dept_audit_by, dept_audit_time, dept_audit_remark, create_by, create_time, update_by, 
      update_time, remark, company_id)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.taskId,jdbcType=INTEGER}, #{item.leasePerson,jdbcType=VARCHAR}, #{item.phone,jdbcType=VARCHAR}, 
        #{item.type,jdbcType=VARCHAR}, #{item.companyAuditBy,jdbcType=INTEGER}, #{item.companyAuditTime,jdbcType=VARCHAR}, 
        #{item.companyAuditRemark,jdbcType=VARCHAR}, #{item.deptAuditBy,jdbcType=INTEGER}, 
        #{item.deptAuditTime,jdbcType=VARCHAR}, #{item.deptAuditRemark,jdbcType=VARCHAR}, 
        #{item.createBy,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateBy,jdbcType=VARCHAR},
        #{item.updateTime,jdbcType=TIMESTAMP}, #{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER}
        )
    </foreach>
  </insert>

  <insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.app.domain.LeaseApplyInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into lease_apply_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      task_id,
      lease_person,
      phone,
      `type`,
      company_audit_by,
      company_audit_time,
      company_audit_remark,
      dept_audit_by,
      dept_audit_time,
      dept_audit_remark,
      create_by,
      create_time,
      update_by,
      update_time,
      remark,
      company_id,
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      #{taskId,jdbcType=INTEGER},
      #{leasePerson,jdbcType=VARCHAR},
      #{phone,jdbcType=VARCHAR},
      #{type,jdbcType=VARCHAR},
      #{companyAuditBy,jdbcType=INTEGER},
      #{companyAuditTime,jdbcType=VARCHAR},
      #{companyAuditRemark,jdbcType=VARCHAR},
      #{deptAuditBy,jdbcType=INTEGER},
      #{deptAuditTime,jdbcType=VARCHAR},
      #{deptAuditRemark,jdbcType=VARCHAR},
      #{createBy,jdbcType=VARCHAR},
      #{createTime,jdbcType=TIMESTAMP},
      #{updateBy,jdbcType=VARCHAR},
      #{updateTime,jdbcType=TIMESTAMP},
      #{remark,jdbcType=VARCHAR},
      #{companyId,jdbcType=INTEGER},
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      task_id = #{taskId,jdbcType=INTEGER},
      lease_person = #{leasePerson,jdbcType=VARCHAR},
      phone = #{phone,jdbcType=VARCHAR},
      `type` = #{type,jdbcType=VARCHAR},
      company_audit_by = #{companyAuditBy,jdbcType=INTEGER},
      company_audit_time = #{companyAuditTime,jdbcType=VARCHAR},
      company_audit_remark = #{companyAuditRemark,jdbcType=VARCHAR},
      dept_audit_by = #{deptAuditBy,jdbcType=INTEGER},
      dept_audit_time = #{deptAuditTime,jdbcType=VARCHAR},
      dept_audit_remark = #{deptAuditRemark,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      remark = #{remark,jdbcType=VARCHAR},
      company_id = #{companyId,jdbcType=INTEGER},
    </trim>
  </insert>

  <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.app.domain.LeaseApplyInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into lease_apply_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="taskId != null">
        task_id,
      </if>
      <if test="leasePerson != null and leasePerson != ''">
        lease_person,
      </if>
      <if test="phone != null and phone != ''">
        phone,
      </if>
      <if test="type != null and type != ''">
        `type`,
      </if>
      <if test="companyAuditBy != null">
        company_audit_by,
      </if>
      <if test="companyAuditTime != null and companyAuditTime != ''">
        company_audit_time,
      </if>
      <if test="companyAuditRemark != null and companyAuditRemark != ''">
        company_audit_remark,
      </if>
      <if test="deptAuditBy != null">
        dept_audit_by,
      </if>
      <if test="deptAuditTime != null and deptAuditTime != ''">
        dept_audit_time,
      </if>
      <if test="deptAuditRemark != null and deptAuditRemark != ''">
        dept_audit_remark,
      </if>
      <if test="createBy != null and createBy != ''">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateBy != null and updateBy != ''">
        update_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="remark != null and remark != ''">
        remark,
      </if>
      <if test="companyId != null">
        company_id,
      </if>
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="taskId != null">
        #{taskId,jdbcType=INTEGER},
      </if>
      <if test="leasePerson != null and leasePerson != ''">
        #{leasePerson,jdbcType=VARCHAR},
      </if>
      <if test="phone != null and phone != ''">
        #{phone,jdbcType=VARCHAR},
      </if>
      <if test="type != null and type != ''">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="companyAuditBy != null">
        #{companyAuditBy,jdbcType=INTEGER},
      </if>
      <if test="companyAuditTime != null and companyAuditTime != ''">
        #{companyAuditTime,jdbcType=VARCHAR},
      </if>
      <if test="companyAuditRemark != null and companyAuditRemark != ''">
        #{companyAuditRemark,jdbcType=VARCHAR},
      </if>
      <if test="deptAuditBy != null">
        #{deptAuditBy,jdbcType=INTEGER},
      </if>
      <if test="deptAuditTime != null and deptAuditTime != ''">
        #{deptAuditTime,jdbcType=VARCHAR},
      </if>
      <if test="deptAuditRemark != null and deptAuditRemark != ''">
        #{deptAuditRemark,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null and createBy != ''">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null and updateBy != ''">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null and remark != ''">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=INTEGER},
      </if>
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      <if test="taskId != null">
        task_id = #{taskId,jdbcType=INTEGER},
      </if>
      <if test="leasePerson != null and leasePerson != ''">
        lease_person = #{leasePerson,jdbcType=VARCHAR},
      </if>
      <if test="phone != null and phone != ''">
        phone = #{phone,jdbcType=VARCHAR},
      </if>
      <if test="type != null and type != ''">
        `type` = #{type,jdbcType=VARCHAR},
      </if>
      <if test="companyAuditBy != null">
        company_audit_by = #{companyAuditBy,jdbcType=INTEGER},
      </if>
      <if test="companyAuditTime != null and companyAuditTime != ''">
        company_audit_time = #{companyAuditTime,jdbcType=VARCHAR},
      </if>
      <if test="companyAuditRemark != null and companyAuditRemark != ''">
        company_audit_remark = #{companyAuditRemark,jdbcType=VARCHAR},
      </if>
      <if test="deptAuditBy != null">
        dept_audit_by = #{deptAuditBy,jdbcType=INTEGER},
      </if>
      <if test="deptAuditTime != null and deptAuditTime != ''">
        dept_audit_time = #{deptAuditTime,jdbcType=VARCHAR},
      </if>
      <if test="deptAuditRemark != null and deptAuditRemark != ''">
        dept_audit_remark = #{deptAuditRemark,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null and createBy != ''">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null and updateBy != ''">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null and remark != ''">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="companyId != null">
        company_id = #{companyId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
</mapper>