<?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.lightinit.hsdataportal.mapper.ContractMapper">
  <resultMap id="BaseResultMap" type="com.lightinit.hsdataportal.entity.Contract">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="user_id" jdbcType="BIGINT" property="userId" />
    <result column="contract_time" jdbcType="TIMESTAMP" property="contractTime" />
    <result column="contract_number" jdbcType="VARCHAR" property="contractNumber" />
    <result column="contract_state" jdbcType="VARCHAR" property="contractState" />
    <result column="contract_name" jdbcType="VARCHAR" property="contractName" />
    <result column="partner_name" jdbcType="VARCHAR" property="partnerName" />
    <result column="effective_time" jdbcType="TIMESTAMP" property="effectiveTime" />
    <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
    <result column="contract_amount" jdbcType="DECIMAL" property="contractAmount" />
    <result column="contact" jdbcType="VARCHAR" property="contact" />
    <result column="contact_info" jdbcType="VARCHAR" property="contactInfo" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="deleted_at" jdbcType="TIMESTAMP" property="deletedAt" />
    <result column="deleted_by" jdbcType="BIGINT" property="deletedBy" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.lightinit.hsdataportal.entity.ContractWithBLOBs">
    <result column="attachment" jdbcType="LONGVARCHAR" property="attachment" />
    <result column="remark" jdbcType="LONGVARCHAR" property="remark" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, user_id, contract_time, contract_number, contract_state, contract_name, partner_name, 
    effective_time, expired_time, contract_amount, contact, contact_info, created_at, 
    created_by, deleted_at, deleted_by
  </sql>
  <sql id="Blob_Column_List">
    attachment, remark
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.lightinit.hsdataportal.entity.ContractExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from contract
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="com.lightinit.hsdataportal.entity.ContractExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from contract
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from contract
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from contract
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.lightinit.hsdataportal.entity.ContractExample">
    delete from contract
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.lightinit.hsdataportal.entity.ContractWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into contract (user_id, contract_time, contract_number, 
      contract_state, contract_name, partner_name, 
      effective_time, expired_time, contract_amount, 
      contact, contact_info, created_at, 
      created_by, deleted_at, deleted_by, 
      attachment, remark)
    values (#{userId,jdbcType=BIGINT}, #{contractTime,jdbcType=TIMESTAMP}, #{contractNumber,jdbcType=VARCHAR}, 
      #{contractState,jdbcType=VARCHAR}, #{contractName,jdbcType=VARCHAR}, #{partnerName,jdbcType=VARCHAR}, 
      #{effectiveTime,jdbcType=TIMESTAMP}, #{expiredTime,jdbcType=TIMESTAMP}, #{contractAmount,jdbcType=DECIMAL}, 
      #{contact,jdbcType=VARCHAR}, #{contactInfo,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, 
      #{createdBy,jdbcType=BIGINT}, #{deletedAt,jdbcType=TIMESTAMP}, #{deletedBy,jdbcType=BIGINT}, 
      #{attachment,jdbcType=LONGVARCHAR}, #{remark,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.lightinit.hsdataportal.entity.ContractWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into contract
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="userId != null">
        user_id,
      </if>
      <if test="contractTime != null">
        contract_time,
      </if>
      <if test="contractNumber != null">
        contract_number,
      </if>
      <if test="contractState != null">
        contract_state,
      </if>
      <if test="contractName != null">
        contract_name,
      </if>
      <if test="partnerName != null">
        partner_name,
      </if>
      <if test="effectiveTime != null">
        effective_time,
      </if>
      <if test="expiredTime != null">
        expired_time,
      </if>
      <if test="contractAmount != null">
        contract_amount,
      </if>
      <if test="contact != null">
        contact,
      </if>
      <if test="contactInfo != null">
        contact_info,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="deletedAt != null">
        deleted_at,
      </if>
      <if test="deletedBy != null">
        deleted_by,
      </if>
      <if test="attachment != null">
        attachment,
      </if>
      <if test="remark != null">
        remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="userId != null">
        #{userId,jdbcType=BIGINT},
      </if>
      <if test="contractTime != null">
        #{contractTime,jdbcType=TIMESTAMP},
      </if>
      <if test="contractNumber != null">
        #{contractNumber,jdbcType=VARCHAR},
      </if>
      <if test="contractState != null">
        #{contractState,jdbcType=VARCHAR},
      </if>
      <if test="contractName != null">
        #{contractName,jdbcType=VARCHAR},
      </if>
      <if test="partnerName != null">
        #{partnerName,jdbcType=VARCHAR},
      </if>
      <if test="effectiveTime != null">
        #{effectiveTime,jdbcType=TIMESTAMP},
      </if>
      <if test="expiredTime != null">
        #{expiredTime,jdbcType=TIMESTAMP},
      </if>
      <if test="contractAmount != null">
        #{contractAmount,jdbcType=DECIMAL},
      </if>
      <if test="contact != null">
        #{contact,jdbcType=VARCHAR},
      </if>
      <if test="contactInfo != null">
        #{contactInfo,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        #{deletedBy,jdbcType=BIGINT},
      </if>
      <if test="attachment != null">
        #{attachment,jdbcType=LONGVARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.lightinit.hsdataportal.entity.ContractExample" resultType="java.lang.Long">
    select count(*) from contract
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update contract
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.userId != null">
        user_id = #{record.userId,jdbcType=BIGINT},
      </if>
      <if test="record.contractTime != null">
        contract_time = #{record.contractTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.contractNumber != null">
        contract_number = #{record.contractNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.contractState != null">
        contract_state = #{record.contractState,jdbcType=VARCHAR},
      </if>
      <if test="record.contractName != null">
        contract_name = #{record.contractName,jdbcType=VARCHAR},
      </if>
      <if test="record.partnerName != null">
        partner_name = #{record.partnerName,jdbcType=VARCHAR},
      </if>
      <if test="record.effectiveTime != null">
        effective_time = #{record.effectiveTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.expiredTime != null">
        expired_time = #{record.expiredTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.contractAmount != null">
        contract_amount = #{record.contractAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.contact != null">
        contact = #{record.contact,jdbcType=VARCHAR},
      </if>
      <if test="record.contactInfo != null">
        contact_info = #{record.contactInfo,jdbcType=VARCHAR},
      </if>
      <if test="record.createdAt != null">
        created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=BIGINT},
      </if>
      <if test="record.deletedAt != null">
        deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.deletedBy != null">
        deleted_by = #{record.deletedBy,jdbcType=BIGINT},
      </if>
      <if test="record.attachment != null">
        attachment = #{record.attachment,jdbcType=LONGVARCHAR},
      </if>
      <if test="record.remark != null">
        remark = #{record.remark,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update contract
    set id = #{record.id,jdbcType=BIGINT},
      user_id = #{record.userId,jdbcType=BIGINT},
      contract_time = #{record.contractTime,jdbcType=TIMESTAMP},
      contract_number = #{record.contractNumber,jdbcType=VARCHAR},
      contract_state = #{record.contractState,jdbcType=VARCHAR},
      contract_name = #{record.contractName,jdbcType=VARCHAR},
      partner_name = #{record.partnerName,jdbcType=VARCHAR},
      effective_time = #{record.effectiveTime,jdbcType=TIMESTAMP},
      expired_time = #{record.expiredTime,jdbcType=TIMESTAMP},
      contract_amount = #{record.contractAmount,jdbcType=DECIMAL},
      contact = #{record.contact,jdbcType=VARCHAR},
      contact_info = #{record.contactInfo,jdbcType=VARCHAR},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=BIGINT},
      deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{record.deletedBy,jdbcType=BIGINT},
      attachment = #{record.attachment,jdbcType=LONGVARCHAR},
      remark = #{record.remark,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update contract
    set id = #{record.id,jdbcType=BIGINT},
      user_id = #{record.userId,jdbcType=BIGINT},
      contract_time = #{record.contractTime,jdbcType=TIMESTAMP},
      contract_number = #{record.contractNumber,jdbcType=VARCHAR},
      contract_state = #{record.contractState,jdbcType=VARCHAR},
      contract_name = #{record.contractName,jdbcType=VARCHAR},
      partner_name = #{record.partnerName,jdbcType=VARCHAR},
      effective_time = #{record.effectiveTime,jdbcType=TIMESTAMP},
      expired_time = #{record.expiredTime,jdbcType=TIMESTAMP},
      contract_amount = #{record.contractAmount,jdbcType=DECIMAL},
      contact = #{record.contact,jdbcType=VARCHAR},
      contact_info = #{record.contactInfo,jdbcType=VARCHAR},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=BIGINT},
      deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{record.deletedBy,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.lightinit.hsdataportal.entity.ContractWithBLOBs">
    update contract
    <set>
      <if test="userId != null">
        user_id = #{userId,jdbcType=BIGINT},
      </if>
      <if test="contractTime != null">
        contract_time = #{contractTime,jdbcType=TIMESTAMP},
      </if>
      <if test="contractNumber != null">
        contract_number = #{contractNumber,jdbcType=VARCHAR},
      </if>
      <if test="contractState != null">
        contract_state = #{contractState,jdbcType=VARCHAR},
      </if>
      <if test="contractName != null">
        contract_name = #{contractName,jdbcType=VARCHAR},
      </if>
      <if test="partnerName != null">
        partner_name = #{partnerName,jdbcType=VARCHAR},
      </if>
      <if test="effectiveTime != null">
        effective_time = #{effectiveTime,jdbcType=TIMESTAMP},
      </if>
      <if test="expiredTime != null">
        expired_time = #{expiredTime,jdbcType=TIMESTAMP},
      </if>
      <if test="contractAmount != null">
        contract_amount = #{contractAmount,jdbcType=DECIMAL},
      </if>
      <if test="contact != null">
        contact = #{contact,jdbcType=VARCHAR},
      </if>
      <if test="contactInfo != null">
        contact_info = #{contactInfo,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        deleted_by = #{deletedBy,jdbcType=BIGINT},
      </if>
      <if test="attachment != null">
        attachment = #{attachment,jdbcType=LONGVARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.lightinit.hsdataportal.entity.ContractWithBLOBs">
    update contract
    set user_id = #{userId,jdbcType=BIGINT},
      contract_time = #{contractTime,jdbcType=TIMESTAMP},
      contract_number = #{contractNumber,jdbcType=VARCHAR},
      contract_state = #{contractState,jdbcType=VARCHAR},
      contract_name = #{contractName,jdbcType=VARCHAR},
      partner_name = #{partnerName,jdbcType=VARCHAR},
      effective_time = #{effectiveTime,jdbcType=TIMESTAMP},
      expired_time = #{expiredTime,jdbcType=TIMESTAMP},
      contract_amount = #{contractAmount,jdbcType=DECIMAL},
      contact = #{contact,jdbcType=VARCHAR},
      contact_info = #{contactInfo,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{deletedBy,jdbcType=BIGINT},
      attachment = #{attachment,jdbcType=LONGVARCHAR},
      remark = #{remark,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.lightinit.hsdataportal.entity.Contract">
    update contract
    set user_id = #{userId,jdbcType=BIGINT},
      contract_time = #{contractTime,jdbcType=TIMESTAMP},
      contract_number = #{contractNumber,jdbcType=VARCHAR},
      contract_state = #{contractState,jdbcType=VARCHAR},
      contract_name = #{contractName,jdbcType=VARCHAR},
      partner_name = #{partnerName,jdbcType=VARCHAR},
      effective_time = #{effectiveTime,jdbcType=TIMESTAMP},
      expired_time = #{expiredTime,jdbcType=TIMESTAMP},
      contract_amount = #{contractAmount,jdbcType=DECIMAL},
      contact = #{contact,jdbcType=VARCHAR},
      contact_info = #{contactInfo,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{deletedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>