<?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.ruoyi.ccdi.mapper.CcdiBizIntermediaryMapper">

    <!-- 批量插入个人中介 -->
    <insert id="insertBatch" parameterType="java.util.List">
        INSERT INTO ccdi_biz_intermediary (
            biz_id, person_type, person_sub_type, relation_type,
            name, gender, id_type, person_id, mobile, wechat_no,
            contact_address, company, social_credit_code, position,
            related_num_id, data_source, remark,
            created_by, updated_by, create_time, update_time
        ) VALUES
        <foreach collection="list" item="item" separator=",">
            (
                #{item.bizId}, #{item.personType}, #{item.personSubType}, #{item.relationType},
                #{item.name}, #{item.gender}, #{item.idType}, #{item.personId}, #{item.mobile}, #{item.wechatNo},
                #{item.contactAddress}, #{item.company}, #{item.socialCreditCode}, #{item.position},
                #{item.relatedNumId}, #{item.dataSource}, #{item.remark},
                #{item.createdBy}, #{item.updatedBy}, #{item.createTime}, #{item.updateTime}
            )
        </foreach>
    </insert>

    <!-- 批量更新个人中介 -->
    <update id="updateBatch" parameterType="java.util.List">
        <foreach collection="list" item="item" separator=";">
            UPDATE ccdi_biz_intermediary
            <set>
                <if test="item.personType != null">person_type = #{item.personType},</if>
                <if test="item.personSubType != null">person_sub_type = #{item.personSubType},</if>
                <if test="item.relationType != null">relation_type = #{item.relationType},</if>
                <if test="item.name != null and item.name != ''">name = #{item.name},</if>
                <if test="item.gender != null">gender = #{item.gender},</if>
                <if test="item.idType != null">id_type = #{item.idType},</if>
                <if test="item.personId != null and item.personId != ''">person_id = #{item.personId},</if>
                <if test="item.mobile != null">mobile = #{item.mobile},</if>
                <if test="item.wechatNo != null">wechat_no = #{item.wechatNo},</if>
                <if test="item.contactAddress != null">contact_address = #{item.contactAddress},</if>
                <if test="item.company != null">company = #{item.company},</if>
                <if test="item.socialCreditCode != null">social_credit_code = #{item.socialCreditCode},</if>
                <if test="item.position != null">position = #{item.position},</if>
                <if test="item.relatedNumId != null">related_num_id = #{item.relatedNumId},</if>
                <if test="item.dataSource != null">data_source = #{item.dataSource},</if>
                <if test="item.remark != null">remark = #{item.remark},</if>
                <if test="item.updatedBy != null">updated_by = #{item.updatedBy},</if>
                update_time = #{item.updateTime}
            </set>
            WHERE biz_id = #{item.bizId}
        </foreach>
    </update>

</mapper>
