<?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.UserCompanyMapper">
  <resultMap id="BaseResultMap" type="com.lightinit.hsdataportal.entity.UserCompany">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="company_name" jdbcType="VARCHAR" property="companyName" />
    <result column="address" jdbcType="VARCHAR" property="address" />
    <result column="commercial_instrument" jdbcType="VARCHAR" property="commercialInstrument" />
    <result column="tax_registration_certificate" jdbcType="VARCHAR" property="taxRegistrationCertificate" />
    <result column="org_code" jdbcType="VARCHAR" property="orgCode" />
    <result column="contact" jdbcType="VARCHAR" property="contact" />
    <result column="id_card" jdbcType="VARCHAR" property="idCard" />
    <result column="phone" jdbcType="VARCHAR" property="phone" />
    <result column="email" jdbcType="VARCHAR" property="email" />
    <result column="service_category" jdbcType="VARCHAR" property="serviceCategory" />
    <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.UserCompanyWithBLOBs">
    <result column="commercial_instrument_copy" jdbcType="LONGVARCHAR" property="commercialInstrumentCopy" />
    <result column="service_tag" jdbcType="LONGVARCHAR" property="serviceTag" />
  </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, company_name, address, commercial_instrument, tax_registration_certificate, org_code, 
    contact, id_card, phone, email, service_category, created_at, created_by, deleted_at, 
    deleted_by
  </sql>
  <sql id="Blob_Column_List">
    commercial_instrument_copy, service_tag
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.lightinit.hsdataportal.entity.UserCompanyExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from user_company
    <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.UserCompanyExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from user_company
    <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 user_company
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from user_company
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.lightinit.hsdataportal.entity.UserCompanyExample">
    delete from user_company
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.lightinit.hsdataportal.entity.UserCompanyWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into user_company (company_name, address, commercial_instrument, 
      tax_registration_certificate, org_code, contact, 
      id_card, phone, email, 
      service_category, created_at, created_by, 
      deleted_at, deleted_by, commercial_instrument_copy, 
      service_tag)
    values (#{companyName,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{commercialInstrument,jdbcType=VARCHAR}, 
      #{taxRegistrationCertificate,jdbcType=VARCHAR}, #{orgCode,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR}, 
      #{idCard,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, 
      #{serviceCategory,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, 
      #{deletedAt,jdbcType=TIMESTAMP}, #{deletedBy,jdbcType=BIGINT}, #{commercialInstrumentCopy,jdbcType=LONGVARCHAR}, 
      #{serviceTag,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.lightinit.hsdataportal.entity.UserCompanyWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into user_company
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="companyName != null">
        company_name,
      </if>
      <if test="address != null">
        address,
      </if>
      <if test="commercialInstrument != null">
        commercial_instrument,
      </if>
      <if test="taxRegistrationCertificate != null">
        tax_registration_certificate,
      </if>
      <if test="orgCode != null">
        org_code,
      </if>
      <if test="contact != null">
        contact,
      </if>
      <if test="idCard != null">
        id_card,
      </if>
      <if test="phone != null">
        phone,
      </if>
      <if test="email != null">
        email,
      </if>
      <if test="serviceCategory != null">
        service_category,
      </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="commercialInstrumentCopy != null">
        commercial_instrument_copy,
      </if>
      <if test="serviceTag != null">
        service_tag,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="companyName != null">
        #{companyName,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        #{address,jdbcType=VARCHAR},
      </if>
      <if test="commercialInstrument != null">
        #{commercialInstrument,jdbcType=VARCHAR},
      </if>
      <if test="taxRegistrationCertificate != null">
        #{taxRegistrationCertificate,jdbcType=VARCHAR},
      </if>
      <if test="orgCode != null">
        #{orgCode,jdbcType=VARCHAR},
      </if>
      <if test="contact != null">
        #{contact,jdbcType=VARCHAR},
      </if>
      <if test="idCard != null">
        #{idCard,jdbcType=VARCHAR},
      </if>
      <if test="phone != null">
        #{phone,jdbcType=VARCHAR},
      </if>
      <if test="email != null">
        #{email,jdbcType=VARCHAR},
      </if>
      <if test="serviceCategory != null">
        #{serviceCategory,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="commercialInstrumentCopy != null">
        #{commercialInstrumentCopy,jdbcType=LONGVARCHAR},
      </if>
      <if test="serviceTag != null">
        #{serviceTag,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.lightinit.hsdataportal.entity.UserCompanyExample" resultType="java.lang.Long">
    select count(*) from user_company
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update user_company
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.companyName != null">
        company_name = #{record.companyName,jdbcType=VARCHAR},
      </if>
      <if test="record.address != null">
        address = #{record.address,jdbcType=VARCHAR},
      </if>
      <if test="record.commercialInstrument != null">
        commercial_instrument = #{record.commercialInstrument,jdbcType=VARCHAR},
      </if>
      <if test="record.taxRegistrationCertificate != null">
        tax_registration_certificate = #{record.taxRegistrationCertificate,jdbcType=VARCHAR},
      </if>
      <if test="record.orgCode != null">
        org_code = #{record.orgCode,jdbcType=VARCHAR},
      </if>
      <if test="record.contact != null">
        contact = #{record.contact,jdbcType=VARCHAR},
      </if>
      <if test="record.idCard != null">
        id_card = #{record.idCard,jdbcType=VARCHAR},
      </if>
      <if test="record.phone != null">
        phone = #{record.phone,jdbcType=VARCHAR},
      </if>
      <if test="record.email != null">
        email = #{record.email,jdbcType=VARCHAR},
      </if>
      <if test="record.serviceCategory != null">
        service_category = #{record.serviceCategory,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.commercialInstrumentCopy != null">
        commercial_instrument_copy = #{record.commercialInstrumentCopy,jdbcType=LONGVARCHAR},
      </if>
      <if test="record.serviceTag != null">
        service_tag = #{record.serviceTag,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update user_company
    set id = #{record.id,jdbcType=BIGINT},
      company_name = #{record.companyName,jdbcType=VARCHAR},
      address = #{record.address,jdbcType=VARCHAR},
      commercial_instrument = #{record.commercialInstrument,jdbcType=VARCHAR},
      tax_registration_certificate = #{record.taxRegistrationCertificate,jdbcType=VARCHAR},
      org_code = #{record.orgCode,jdbcType=VARCHAR},
      contact = #{record.contact,jdbcType=VARCHAR},
      id_card = #{record.idCard,jdbcType=VARCHAR},
      phone = #{record.phone,jdbcType=VARCHAR},
      email = #{record.email,jdbcType=VARCHAR},
      service_category = #{record.serviceCategory,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},
      commercial_instrument_copy = #{record.commercialInstrumentCopy,jdbcType=LONGVARCHAR},
      service_tag = #{record.serviceTag,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update user_company
    set id = #{record.id,jdbcType=BIGINT},
      company_name = #{record.companyName,jdbcType=VARCHAR},
      address = #{record.address,jdbcType=VARCHAR},
      commercial_instrument = #{record.commercialInstrument,jdbcType=VARCHAR},
      tax_registration_certificate = #{record.taxRegistrationCertificate,jdbcType=VARCHAR},
      org_code = #{record.orgCode,jdbcType=VARCHAR},
      contact = #{record.contact,jdbcType=VARCHAR},
      id_card = #{record.idCard,jdbcType=VARCHAR},
      phone = #{record.phone,jdbcType=VARCHAR},
      email = #{record.email,jdbcType=VARCHAR},
      service_category = #{record.serviceCategory,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.UserCompanyWithBLOBs">
    update user_company
    <set>
      <if test="companyName != null">
        company_name = #{companyName,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        address = #{address,jdbcType=VARCHAR},
      </if>
      <if test="commercialInstrument != null">
        commercial_instrument = #{commercialInstrument,jdbcType=VARCHAR},
      </if>
      <if test="taxRegistrationCertificate != null">
        tax_registration_certificate = #{taxRegistrationCertificate,jdbcType=VARCHAR},
      </if>
      <if test="orgCode != null">
        org_code = #{orgCode,jdbcType=VARCHAR},
      </if>
      <if test="contact != null">
        contact = #{contact,jdbcType=VARCHAR},
      </if>
      <if test="idCard != null">
        id_card = #{idCard,jdbcType=VARCHAR},
      </if>
      <if test="phone != null">
        phone = #{phone,jdbcType=VARCHAR},
      </if>
      <if test="email != null">
        email = #{email,jdbcType=VARCHAR},
      </if>
      <if test="serviceCategory != null">
        service_category = #{serviceCategory,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="commercialInstrumentCopy != null">
        commercial_instrument_copy = #{commercialInstrumentCopy,jdbcType=LONGVARCHAR},
      </if>
      <if test="serviceTag != null">
        service_tag = #{serviceTag,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.lightinit.hsdataportal.entity.UserCompanyWithBLOBs">
    update user_company
    set company_name = #{companyName,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      commercial_instrument = #{commercialInstrument,jdbcType=VARCHAR},
      tax_registration_certificate = #{taxRegistrationCertificate,jdbcType=VARCHAR},
      org_code = #{orgCode,jdbcType=VARCHAR},
      contact = #{contact,jdbcType=VARCHAR},
      id_card = #{idCard,jdbcType=VARCHAR},
      phone = #{phone,jdbcType=VARCHAR},
      email = #{email,jdbcType=VARCHAR},
      service_category = #{serviceCategory,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{deletedBy,jdbcType=BIGINT},
      commercial_instrument_copy = #{commercialInstrumentCopy,jdbcType=LONGVARCHAR},
      service_tag = #{serviceTag,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.lightinit.hsdataportal.entity.UserCompany">
    update user_company
    set company_name = #{companyName,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      commercial_instrument = #{commercialInstrument,jdbcType=VARCHAR},
      tax_registration_certificate = #{taxRegistrationCertificate,jdbcType=VARCHAR},
      org_code = #{orgCode,jdbcType=VARCHAR},
      contact = #{contact,jdbcType=VARCHAR},
      id_card = #{idCard,jdbcType=VARCHAR},
      phone = #{phone,jdbcType=VARCHAR},
      email = #{email,jdbcType=VARCHAR},
      service_category = #{serviceCategory,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>

  <!--sun-->
  <insert id="insertUserCompany" parameterType="com.lightinit.hsdataportal.entity.UserCompanyWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into user_company (id,company_name, address, commercial_instrument,
    tax_registration_certificate, org_code, contact,
    id_card, phone, email,
    service_category, created_at, created_by,
    deleted_at, deleted_by, commercial_instrument_copy,
    service_tag)
    values (#{id,jdbcType=BIGINT},#{companyName,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{commercialInstrument,jdbcType=VARCHAR},
    #{taxRegistrationCertificate,jdbcType=VARCHAR}, #{orgCode,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR},
    #{idCard,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR},
    #{serviceCategory,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT},
    #{deletedAt,jdbcType=TIMESTAMP}, #{deletedBy,jdbcType=BIGINT}, #{commercialInstrumentCopy,jdbcType=LONGVARCHAR},
    #{serviceTag,jdbcType=LONGVARCHAR})
  </insert>
</mapper>