<?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.ibs.list.mapper.FamilyMembersRecordMapper">
    
    <resultMap type="FamilyMembersRecord" id="FamilyMembersRecordResult">
        <result property="id"    column="id"    />
        <result property="custIdc"    column="cust_idc"    />
        <result property="fmyName"    column="fmy_name"    />
        <result property="tel"    column="tel"    />
        <result property="birthday"    column="birthday"    />
        <result property="fmyRln"    column="fmy_rln"    />
        <result property="belongBusi"    column="belong_busi"    />
        <result property="fmyCustIdc"    column="fmy_cust_idc"    />
        <result property="recordId"    column="record_id"    />
    </resultMap>

    <sql id="selectFamilyMembersRecordVo">
        select id,cust_idc, fmy_name, tel, birthday, fmy_rln, belong_busi, fmy_cust_idc,record_id from family_members_record
    </sql>

    <select id="selectFamilyMembersRecordList" parameterType="FamilyMembersRecord" resultMap="FamilyMembersRecordResult">
        <include refid="selectFamilyMembersRecordVo"/>
        <where>  
            <if test="custIdc != null  and custIdc != ''"> and cust_idc = #{custIdc}</if>
            <if test="fmyName != null  and fmyName != ''"> and fmy_name like concat('%', #{fmyName}, '%')</if>
            <if test="tel != null  and tel != ''"> and tel = #{tel}</if>
            <if test="birthday != null "> and birthday = #{birthday}</if>
            <if test="fmyRln != null  and fmyRln != ''"> and fmy_rln = #{fmyRln}</if>
            <if test="belongBusi != null  and belongBusi != ''"> and belong_busi = #{belongBusi}</if>
            <if test="fmyCustIdc != null  and fmyCustIdc != ''"> and fmy_cust_idc = #{fmyCustIdc}</if>
            <if test="recordId != null "> and record_id = #{recordId}</if>
        </where>
    </select>
    
    <select id="selectFamilyMembersRecordByCustIdc" parameterType="String" resultMap="FamilyMembersRecordResult">
        <include refid="selectFamilyMembersRecordVo"/>
        where cust_idc = #{custIdc}
    </select>

    <insert id="insertFamilyMembersRecord" parameterType="FamilyMembersRecord">
        insert into family_members_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="custIdc != null">cust_idc,</if>
            <if test="fmyName != null">fmy_name,</if>
            <if test="tel != null">tel,</if>
            <if test="birthday != null">birthday,</if>
            <if test="fmyRln != null">fmy_rln,</if>
            <if test="belongBusi != null">belong_busi,</if>
            <if test="fmyCustIdc != null">fmy_cust_idc,</if>
            <if test="recordId != null">record_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="custIdc != null">#{custIdc},</if>
            <if test="fmyName != null">#{fmyName},</if>
            <if test="tel != null">#{tel},</if>
            <if test="birthday != null">#{birthday},</if>
            <if test="fmyRln != null">#{fmyRln},</if>
            <if test="belongBusi != null">#{belongBusi},</if>
            <if test="fmyCustIdc != null">#{fmyCustIdc},</if>
            <if test="recordId != null">#{recordId},</if>
         </trim>
    </insert>

    <update id="updateFamilyMembersRecord" parameterType="FamilyMembersRecord">
        update family_members_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="fmyName != null">fmy_name = #{fmyName},</if>
            <if test="tel != null">tel = #{tel},</if>
            <if test="birthday != null">birthday = #{birthday},</if>
            <if test="fmyRln != null">fmy_rln = #{fmyRln},</if>
            <if test="belongBusi != null">belong_busi = #{belongBusi},</if>
            <if test="fmyCustIdc != null">fmy_cust_idc = #{fmyCustIdc},</if>
            <if test="recordId != null">record_id = #{recordId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFamilyMembersRecordByCustIdc" parameterType="String">
        delete from family_members_record where cust_idc = #{custIdc}
    </delete>

    <delete id="deleteFamilyMembersRecordByCustIdcs" parameterType="String">
        delete from family_members_record where cust_idc in 
        <foreach item="custIdc" collection="array" open="(" separator="," close=")">
            #{custIdc}
        </foreach>
    </delete>
</mapper>