<?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.yd.dal.mapper.customer.AclInsurerBranchMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.customer.AclInsurerBranch">
    <!--@mbg.generated-->
    <!--@Table ag_acl_insurer_branch-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="branch_code" jdbcType="VARCHAR" property="branchCode" />
    <result column="insurer_id" jdbcType="BIGINT" property="insurerId" />
    <result column="insurer_name" jdbcType="VARCHAR" property="insurerName" />
    <result column="branch_name" jdbcType="VARCHAR" property="branchName" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="effective_start_date" jdbcType="DATE" property="effectiveStartDate" />
    <result column="effective_end_date" jdbcType="DATE" property="effectiveEndDate" />
    <result column="contact_name" jdbcType="VARCHAR" property="contactName" />
    <result column="contact_no" jdbcType="VARCHAR" property="contactNo" />
    <result column="address" jdbcType="VARCHAR" property="address" />
    <result column="electronic_tax_seal" jdbcType="VARCHAR" property="electronicTaxSeal" />
    <result column="remark" jdbcType="LONGVARCHAR" property="remark" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
    <result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, branch_code, insurer_id, insurer_name, branch_name, is_active, effective_start_date, 
    effective_end_date, contact_name, contact_no, address, electronic_tax_seal, remark, 
    created_at, created_by, updated_at, updated_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from ag_acl_insurer_branch
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ag_acl_insurer_branch
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclInsurerBranch" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_acl_insurer_branch (branch_code, insurer_id, insurer_name, 
      branch_name, is_active, effective_start_date, 
      effective_end_date, contact_name, contact_no, 
      address, electronic_tax_seal, remark, 
      created_at, created_by, updated_at, 
      updated_by)
    values (#{branchCode,jdbcType=VARCHAR}, #{insurerId,jdbcType=BIGINT}, #{insurerName,jdbcType=VARCHAR}, 
      #{branchName,jdbcType=VARCHAR}, #{isActive,jdbcType=INTEGER}, #{effectiveStartDate,jdbcType=DATE}, 
      #{effectiveEndDate,jdbcType=DATE}, #{contactName,jdbcType=VARCHAR}, #{contactNo,jdbcType=VARCHAR}, 
      #{address,jdbcType=VARCHAR}, #{electronicTaxSeal,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR}, 
      #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, 
      #{updatedBy,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclInsurerBranch" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_acl_insurer_branch
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="branchCode != null">
        branch_code,
      </if>
      <if test="insurerId != null">
        insurer_id,
      </if>
      <if test="insurerName != null">
        insurer_name,
      </if>
      <if test="branchName != null">
        branch_name,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="effectiveStartDate != null">
        effective_start_date,
      </if>
      <if test="effectiveEndDate != null">
        effective_end_date,
      </if>
      <if test="contactName != null">
        contact_name,
      </if>
      <if test="contactNo != null">
        contact_no,
      </if>
      <if test="address != null">
        address,
      </if>
      <if test="electronicTaxSeal != null">
        electronic_tax_seal,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedAt != null">
        updated_at,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="branchCode != null">
        #{branchCode,jdbcType=VARCHAR},
      </if>
      <if test="insurerId != null">
        #{insurerId,jdbcType=BIGINT},
      </if>
      <if test="insurerName != null">
        #{insurerName,jdbcType=VARCHAR},
      </if>
      <if test="branchName != null">
        #{branchName,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="effectiveStartDate != null">
        #{effectiveStartDate,jdbcType=DATE},
      </if>
      <if test="effectiveEndDate != null">
        #{effectiveEndDate,jdbcType=DATE},
      </if>
      <if test="contactName != null">
        #{contactName,jdbcType=VARCHAR},
      </if>
      <if test="contactNo != null">
        #{contactNo,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        #{address,jdbcType=VARCHAR},
      </if>
      <if test="electronicTaxSeal != null">
        #{electronicTaxSeal,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=LONGVARCHAR},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.customer.AclInsurerBranch">
    <!--@mbg.generated-->
    update ag_acl_insurer_branch
    <set>
      <if test="branchCode != null">
        branch_code = #{branchCode,jdbcType=VARCHAR},
      </if>
      <if test="insurerId != null">
        insurer_id = #{insurerId,jdbcType=BIGINT},
      </if>
      <if test="insurerName != null">
        insurer_name = #{insurerName,jdbcType=VARCHAR},
      </if>
      <if test="branchName != null">
        branch_name = #{branchName,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="effectiveStartDate != null">
        effective_start_date = #{effectiveStartDate,jdbcType=DATE},
      </if>
      <if test="effectiveEndDate != null">
        effective_end_date = #{effectiveEndDate,jdbcType=DATE},
      </if>
      <if test="contactName != null">
        contact_name = #{contactName,jdbcType=VARCHAR},
      </if>
      <if test="contactNo != null">
        contact_no = #{contactNo,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        address = #{address,jdbcType=VARCHAR},
      </if>
      <if test="electronicTaxSeal != null">
        electronic_tax_seal = #{electronicTaxSeal,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=LONGVARCHAR},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.customer.AclInsurerBranch">
    <!--@mbg.generated-->
    update ag_acl_insurer_branch
    set branch_code = #{branchCode,jdbcType=VARCHAR},
      insurer_id = #{insurerId,jdbcType=BIGINT},
      insurer_name = #{insurerName,jdbcType=VARCHAR},
      branch_name = #{branchName,jdbcType=VARCHAR},
      is_active = #{isActive,jdbcType=INTEGER},
      effective_start_date = #{effectiveStartDate,jdbcType=DATE},
      effective_end_date = #{effectiveEndDate,jdbcType=DATE},
      contact_name = #{contactName,jdbcType=VARCHAR},
      contact_no = #{contactNo,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      electronic_tax_seal = #{electronicTaxSeal,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=LONGVARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update ag_acl_insurer_branch
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="branch_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.branchCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="insurer_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.insurerId,jdbcType=BIGINT}
        </foreach>
      </trim>
      <trim prefix="insurer_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.insurerName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="branch_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.branchName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="is_active = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.isActive,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="effective_start_date = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.effectiveStartDate,jdbcType=DATE}
        </foreach>
      </trim>
      <trim prefix="effective_end_date = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.effectiveEndDate,jdbcType=DATE}
        </foreach>
      </trim>
      <trim prefix="contact_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.contactName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="contact_no = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.contactNo,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="address = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.address,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="electronic_tax_seal = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.electronicTaxSeal,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.remark,jdbcType=LONGVARCHAR}
        </foreach>
      </trim>
      <trim prefix="created_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="created_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
        </foreach>
      </trim>
      <trim prefix="updated_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="updated_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <update id="updateBatchSelective" parameterType="java.util.List">
    <!--@mbg.generated-->
    update ag_acl_insurer_branch
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="branch_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.branchCode != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.branchCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="insurer_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.insurerId != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.insurerId,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
      <trim prefix="insurer_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.insurerName != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.insurerName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="branch_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.branchName != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.branchName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="is_active = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.isActive != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.isActive,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="effective_start_date = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.effectiveStartDate != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.effectiveStartDate,jdbcType=DATE}
          </if>
        </foreach>
      </trim>
      <trim prefix="effective_end_date = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.effectiveEndDate != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.effectiveEndDate,jdbcType=DATE}
          </if>
        </foreach>
      </trim>
      <trim prefix="contact_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.contactName != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.contactName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="contact_no = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.contactNo != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.contactNo,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="address = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.address != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.address,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="electronic_tax_seal = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.electronicTaxSeal != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.electronicTaxSeal,jdbcType=VARCHAR}
          </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=BIGINT} then #{item.remark,jdbcType=LONGVARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="created_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createdAt != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="created_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createdBy != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
      <trim prefix="updated_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updatedAt != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="updated_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updatedBy != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_acl_insurer_branch
    (branch_code, insurer_id, insurer_name, branch_name, is_active, effective_start_date, 
      effective_end_date, contact_name, contact_no, address, electronic_tax_seal, remark, 
      created_at, created_by, updated_at, updated_by)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.branchCode,jdbcType=VARCHAR}, #{item.insurerId,jdbcType=BIGINT}, #{item.insurerName,jdbcType=VARCHAR}, 
        #{item.branchName,jdbcType=VARCHAR}, #{item.isActive,jdbcType=INTEGER}, #{item.effectiveStartDate,jdbcType=DATE}, 
        #{item.effectiveEndDate,jdbcType=DATE}, #{item.contactName,jdbcType=VARCHAR}, #{item.contactNo,jdbcType=VARCHAR}, 
        #{item.address,jdbcType=VARCHAR}, #{item.electronicTaxSeal,jdbcType=VARCHAR}, #{item.remark,jdbcType=LONGVARCHAR}, 
        #{item.createdAt,jdbcType=TIMESTAMP}, #{item.createdBy,jdbcType=BIGINT}, #{item.updatedAt,jdbcType=TIMESTAMP}, 
        #{item.updatedBy,jdbcType=BIGINT})
    </foreach>
  </insert>
</mapper>