<?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.BmAgreementInfoMapper">
  <resultMap id="BaseResultMap" type="com.bonus.sgzb.app.domain.BmAgreementInfo">
    <!--@mbg.generated-->
    <!--@Table bm_agreement_info-->
    <id column="agreement_id" jdbcType="INTEGER" property="agreementId" />
    <result column="agreement_code" jdbcType="VARCHAR" property="agreementCode" />
    <result column="sign_time" jdbcType="VARCHAR" property="signTime" />
    <result column="unit_id" jdbcType="INTEGER" property="unitId" />
    <result column="project_id" jdbcType="INTEGER" property="projectId" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="lease_day" jdbcType="INTEGER" property="leaseDay" />
    <result column="plan_start_time" jdbcType="TIMESTAMP" property="planStartTime" />
    <result column="contract_code" jdbcType="VARCHAR" property="contractCode" />
    <result column="auth_person" jdbcType="VARCHAR" property="authPerson" />
    <result column="phone" jdbcType="VARCHAR" property="phone" />
    <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-->
    agreement_id, agreement_code, sign_time, unit_id, project_id, create_by, lease_day, 
    plan_start_time, contract_code, auth_person, phone, 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 bm_agreement_info
    where agreement_id = #{agreementId,jdbcType=INTEGER}
  </select>

  <select id="isPrimaryByProAndUnit" resultType="java.lang.Integer">
    select count(1) from bm_agreement_info
    where unit_id = #{unitId,jdbcType=INTEGER} and project_id = #{projectId,jdbcType=INTEGER}
  </select>


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

  <insert id="insert" keyColumn="agreement_id" keyProperty="agreementId" parameterType="com.bonus.sgzb.app.domain.BmAgreementInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_agreement_info (agreement_code, sign_time, unit_id, 
      project_id, create_by, lease_day, 
      plan_start_time, contract_code, auth_person, 
      phone, create_time, update_by, 
      update_time, remark, company_id
      )
    values (#{agreementCode,jdbcType=VARCHAR}, #{signTime,jdbcType=VARCHAR}, #{unitId,jdbcType=INTEGER}, 
      #{projectId,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR}, #{leaseDay,jdbcType=INTEGER}, 
      #{planStartTime,jdbcType=TIMESTAMP}, #{contractCode,jdbcType=VARCHAR}, #{authPerson,jdbcType=VARCHAR}, 
      #{phone,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, 
      #{updateTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}
      )
  </insert>

  <insert id="insertSelective" keyColumn="agreement_id" keyProperty="agreementId" parameterType="com.bonus.sgzb.app.domain.BmAgreementInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into bm_agreement_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="agreementCode != null and agreementCode != ''">
        agreement_code,
      </if>
      <if test="signTime != null and signTime != ''">
        sign_time,
      </if>
      <if test="unitId != null">
        unit_id,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="createBy != null and createBy != ''">
        create_by,
      </if>
      <if test="leaseDay != null">
        lease_day,
      </if>
      <if test="planStartTime != null">
        plan_start_time,
      </if>
      <if test="contractCode != null and contractCode != ''">
        contract_code,
      </if>
      <if test="authPerson != null and authPerson != ''">
        auth_person,
      </if>
      <if test="phone != null and phone != ''">
        phone,
      </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>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="agreementCode != null and agreementCode != ''">
        #{agreementCode,jdbcType=VARCHAR},
      </if>
      <if test="signTime != null and signTime != ''">
        #{signTime,jdbcType=VARCHAR},
      </if>
      <if test="unitId != null">
        #{unitId,jdbcType=INTEGER},
      </if>
      <if test="projectId != null">
        #{projectId,jdbcType=INTEGER},
      </if>
      <if test="createBy != null and createBy != ''">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="leaseDay != null">
        #{leaseDay,jdbcType=INTEGER},
      </if>
      <if test="planStartTime != null">
        #{planStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="contractCode != null and contractCode != ''">
        #{contractCode,jdbcType=VARCHAR},
      </if>
      <if test="authPerson != null and authPerson != ''">
        #{authPerson,jdbcType=VARCHAR},
      </if>
      <if test="phone != null and phone != ''">
        #{phone,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>
  </insert>

  <update id="updateByPrimaryKeySelective" parameterType="com.bonus.sgzb.app.domain.BmAgreementInfo">
    <!--@mbg.generated-->
    update bm_agreement_info
    <set>
      <if test="agreementCode != null and agreementCode != ''">
        agreement_code = #{agreementCode,jdbcType=VARCHAR},
      </if>
      <if test="signTime != null and signTime != ''">
        sign_time = #{signTime,jdbcType=VARCHAR},
      </if>
      <if test="unitId != null">
        unit_id = #{unitId,jdbcType=INTEGER},
      </if>
      <if test="projectId != null">
        project_id = #{projectId,jdbcType=INTEGER},
      </if>
      <if test="createBy != null and createBy != ''">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="leaseDay != null">
        lease_day = #{leaseDay,jdbcType=INTEGER},
      </if>
      <if test="planStartTime != null">
        plan_start_time = #{planStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="contractCode != null and contractCode != ''">
        contract_code = #{contractCode,jdbcType=VARCHAR},
      </if>
      <if test="authPerson != null and authPerson != ''">
        auth_person = #{authPerson,jdbcType=VARCHAR},
      </if>
      <if test="phone != null and phone != ''">
        phone = #{phone,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>
    </set>
    where agreement_id = #{agreementId,jdbcType=INTEGER}
  </update>

  <update id="updateByPrimaryKey" parameterType="com.bonus.sgzb.app.domain.BmAgreementInfo">
    <!--@mbg.generated-->
    update bm_agreement_info
    set agreement_code = #{agreementCode,jdbcType=VARCHAR},
      sign_time = #{signTime,jdbcType=VARCHAR},
      unit_id = #{unitId,jdbcType=INTEGER},
      project_id = #{projectId,jdbcType=INTEGER},
      create_by = #{createBy,jdbcType=VARCHAR},
      lease_day = #{leaseDay,jdbcType=INTEGER},
      plan_start_time = #{planStartTime,jdbcType=TIMESTAMP},
      contract_code = #{contractCode,jdbcType=VARCHAR},
      auth_person = #{authPerson,jdbcType=VARCHAR},
      phone = #{phone,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}
    where agreement_id = #{agreementId,jdbcType=INTEGER}
  </update>

</mapper>