<?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.AclInsurerBranchDeptMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.customer.AclInsurerBranchDept">
    <!--@mbg.generated-->
    <!--@Table ag_acl_insurer_branch_dept-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="insurer_id" jdbcType="BIGINT" property="insurerId" />
    <result column="insurer_branch_id" jdbcType="BIGINT" property="insurerBranchId" />
    <result column="dept_code" jdbcType="VARCHAR" property="deptCode" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="name_en" jdbcType="VARCHAR" property="nameEn" />
    <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="VARCHAR" property="remark" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <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, insurer_id, insurer_branch_id, dept_code, `name`, name_en, contact_name, contact_no, 
    address, electronic_tax_seal, remark, is_active, 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_dept
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ag_acl_insurer_branch_dept
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclInsurerBranchDept" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_acl_insurer_branch_dept (insurer_id, insurer_branch_id, dept_code, 
      `name`, name_en, contact_name, 
      contact_no, address, electronic_tax_seal, 
      remark, is_active, created_at, 
      created_by, updated_at, updated_by
      )
    values (#{insurerId,jdbcType=BIGINT}, #{insurerBranchId,jdbcType=BIGINT}, #{deptCode,jdbcType=VARCHAR}, 
      #{name,jdbcType=VARCHAR}, #{nameEn,jdbcType=VARCHAR}, #{contactName,jdbcType=VARCHAR}, 
      #{contactNo,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{electronicTaxSeal,jdbcType=VARCHAR}, 
      #{remark,jdbcType=VARCHAR}, #{isActive,jdbcType=INTEGER}, #{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.AclInsurerBranchDept" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_acl_insurer_branch_dept
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="insurerId != null">
        insurer_id,
      </if>
      <if test="insurerBranchId != null">
        insurer_branch_id,
      </if>
      <if test="deptCode != null">
        dept_code,
      </if>
      <if test="name != null">
        `name`,
      </if>
      <if test="nameEn != null">
        name_en,
      </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="isActive != null">
        is_active,
      </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="insurerId != null">
        #{insurerId,jdbcType=BIGINT},
      </if>
      <if test="insurerBranchId != null">
        #{insurerBranchId,jdbcType=BIGINT},
      </if>
      <if test="deptCode != null">
        #{deptCode,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="nameEn != null">
        #{nameEn,jdbcType=VARCHAR},
      </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=VARCHAR},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </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.AclInsurerBranchDept">
    <!--@mbg.generated-->
    update ag_acl_insurer_branch_dept
    <set>
      <if test="insurerId != null">
        insurer_id = #{insurerId,jdbcType=BIGINT},
      </if>
      <if test="insurerBranchId != null">
        insurer_branch_id = #{insurerBranchId,jdbcType=BIGINT},
      </if>
      <if test="deptCode != null">
        dept_code = #{deptCode,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="nameEn != null">
        name_en = #{nameEn,jdbcType=VARCHAR},
      </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=VARCHAR},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </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.AclInsurerBranchDept">
    <!--@mbg.generated-->
    update ag_acl_insurer_branch_dept
    set insurer_id = #{insurerId,jdbcType=BIGINT},
      insurer_branch_id = #{insurerBranchId,jdbcType=BIGINT},
      dept_code = #{deptCode,jdbcType=VARCHAR},
      `name` = #{name,jdbcType=VARCHAR},
      name_en = #{nameEn,jdbcType=VARCHAR},
      contact_name = #{contactName,jdbcType=VARCHAR},
      contact_no = #{contactNo,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      electronic_tax_seal = #{electronicTaxSeal,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      is_active = #{isActive,jdbcType=INTEGER},
      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_dept
    <trim prefix="set" suffixOverrides=",">
      <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_branch_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.insurerBranchId,jdbcType=BIGINT}
        </foreach>
      </trim>
      <trim prefix="dept_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.deptCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="`name` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.name,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="name_en = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.nameEn,jdbcType=VARCHAR}
        </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=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="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_dept
    <trim prefix="set" suffixOverrides=",">
      <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_branch_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.insurerBranchId != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.insurerBranchId,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
      <trim prefix="dept_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.deptCode != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.deptCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="`name` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.name != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.name,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="name_en = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.nameEn != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.nameEn,jdbcType=VARCHAR}
          </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=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="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_dept
    (insurer_id, insurer_branch_id, dept_code, `name`, name_en, contact_name, contact_no, 
      address, electronic_tax_seal, remark, is_active, created_at, created_by, updated_at, 
      updated_by)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.insurerId,jdbcType=BIGINT}, #{item.insurerBranchId,jdbcType=BIGINT}, #{item.deptCode,jdbcType=VARCHAR}, 
        #{item.name,jdbcType=VARCHAR}, #{item.nameEn,jdbcType=VARCHAR}, #{item.contactName,jdbcType=VARCHAR}, 
        #{item.contactNo,jdbcType=VARCHAR}, #{item.address,jdbcType=VARCHAR}, #{item.electronicTaxSeal,jdbcType=VARCHAR}, 
        #{item.remark,jdbcType=VARCHAR}, #{item.isActive,jdbcType=INTEGER}, #{item.createdAt,jdbcType=TIMESTAMP}, 
        #{item.createdBy,jdbcType=BIGINT}, #{item.updatedAt,jdbcType=TIMESTAMP}, #{item.updatedBy,jdbcType=BIGINT}
        )
    </foreach>
  </insert>
</mapper>