<?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.project.benyi.mapper.ByChildContactpeopleMapper">

    <resultMap type="ByChildContactpeople" id="ByChildContactpeopleResult">
        <result property="id" column="id"/>
        <result property="childid" column="childid"/>
        <result property="schoolid" column="schoolid"/>
        <result property="classid" column="classid"/>
        <result property="fathername" column="fathername"/>
        <result property="fphone" column="fphone"/>
        <result property="foffphone" column="foffphone"/>
        <result property="mothername" column="mothername"/>
        <result property="mphone" column="mphone"/>
        <result property="moffphone" column="moffphone"/>
        <result property="grandfathername" column="grandfathername"/>
        <result property="gfgx" column="gfgx"/>
        <result property="gfphone" column="gfphone"/>
        <result property="gfoffphone" column="gfoffphone"/>
        <result property="gfaddress" column="gfaddress"/>
        <result property="grandmothername" column="grandmothername"/>
        <result property="gmgx" column="gmgx"/>
        <result property="gmphone" column="gmphone"/>
        <result property="gmaddress" column="gmaddress"/>
        <result property="gmoffphone" column="gmoffphone"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <sql id="selectByChildContactpeopleVo">
        select a.id, a.childid, a.fathername, a.fphone, a.foffphone, a.mothername, a.mphone, a.moffphone, a.grandfathername, a.gfgx, a.gfphone, a.gfoffphone, a.gfaddress, a.grandmothername, a.gmgx, a.gmphone, a.gmaddress, a.gmoffphone, a.create_time,b.schoolid, b.classid from by_child_contactpeople a left join by_child b on a.childid=b.id
    </sql>

    <select id="selectByChildContactpeopleList" parameterType="ByChildContactpeople"
            resultMap="ByChildContactpeopleResult">
        <include refid="selectByChildContactpeopleVo"/>
        <where>
            <if test="childid != null ">and a.childid = #{childid}</if>
            <if test="schoolid != null ">and b.schoolid = #{schoolid}</if>
            <if test="classid != null  and classid != ''">and b.classid = #{classid}</if>
            <if test="fathername != null  and fathername != ''">and a.fathername like concat('%', #{fathername}, '%')</if>
            <if test="fphone != null  and fphone != ''">and a.fphone = #{fphone}</if>
            <if test="foffphone != null  and foffphone != ''">and a.foffphone = #{foffphone}</if>
            <if test="mothername != null  and mothername != ''">and a.mothername like concat('%', #{mothername}, '%')</if>
            <if test="mphone != null  and mphone != ''">and a.mphone = #{mphone}</if>
            <if test="moffphone != null  and moffphone != ''">and a.moffphone = #{moffphone}</if>
            <if test="grandfathername != null  and grandfathername != ''">and a.grandfathername like concat('%',
                #{grandfathername}, '%')
            </if>
            <if test="gfgx != null  and gfgx != ''">and a.gfgx = #{gfgx}</if>
            <if test="gfphone != null  and gfphone != ''">and a.gfphone = #{gfphone}</if>
            <if test="gfoffphone != null  and gfoffphone != ''">and a.gfoffphone = #{gfoffphone}</if>
            <if test="gfaddress != null  and gfaddress != ''">and a.gfaddress = #{gfaddress}</if>
            <if test="grandmothername != null  and grandmothername != ''">and a.grandmothername like concat('%',
                #{grandmothername}, '%')
            </if>
            <if test="gmgx != null  and gmgx != ''">and a.gmgx = #{gmgx}</if>
            <if test="gmphone != null  and gmphone != ''">and a.gmphone = #{gmphone}</if>
            <if test="gmaddress != null  and gmaddress != ''">and a.gmaddress = #{gmaddress}</if>
            <if test="gmoffphone != null  and gmoffphone != ''">and a.gmoffphone = #{gmoffphone}</if>
        </where>
    </select>

    <select id="selectByChildContactpeopleById" parameterType="Long" resultMap="ByChildContactpeopleResult">
        <include refid="selectByChildContactpeopleVo"/>
        where a.id = #{id}
    </select>

    <insert id="insertByChildContactpeople" parameterType="ByChildContactpeople">
        insert into by_child_contactpeople
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null ">id,</if>
            <if test="childid != null ">childid,</if>
            <if test="fathername != null  and fathername != ''">fathername,</if>
            <if test="fphone != null  and fphone != ''">fphone,</if>
            <if test="foffphone != null  and foffphone != ''">foffphone,</if>
            <if test="mothername != null  and mothername != ''">mothername,</if>
            <if test="mphone != null  and mphone != ''">mphone,</if>
            <if test="moffphone != null  and moffphone != ''">moffphone,</if>
            <if test="grandfathername != null  and grandfathername != ''">grandfathername,</if>
            <if test="gfgx != null  and gfgx != ''">gfgx,</if>
            <if test="gfphone != null  and gfphone != ''">gfphone,</if>
            <if test="gfoffphone != null  and gfoffphone != ''">gfoffphone,</if>
            <if test="gfaddress != null  and gfaddress != ''">gfaddress,</if>
            <if test="grandmothername != null  and grandmothername != ''">grandmothername,</if>
            <if test="gmgx != null  and gmgx != ''">gmgx,</if>
            <if test="gmphone != null  and gmphone != ''">gmphone,</if>
            <if test="gmaddress != null  and gmaddress != ''">gmaddress,</if>
            <if test="gmoffphone != null  and gmoffphone != ''">gmoffphone,</if>
            <if test="createTime != null ">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null ">#{id},</if>
            <if test="childid != null ">#{childid},</if>
            <if test="fathername != null  and fathername != ''">#{fathername},</if>
            <if test="fphone != null  and fphone != ''">#{fphone},</if>
            <if test="foffphone != null  and foffphone != ''">#{foffphone},</if>
            <if test="mothername != null  and mothername != ''">#{mothername},</if>
            <if test="mphone != null  and mphone != ''">#{mphone},</if>
            <if test="moffphone != null  and moffphone != ''">#{moffphone},</if>
            <if test="grandfathername != null  and grandfathername != ''">#{grandfathername},</if>
            <if test="gfgx != null  and gfgx != ''">#{gfgx},</if>
            <if test="gfphone != null  and gfphone != ''">#{gfphone},</if>
            <if test="gfoffphone != null  and gfoffphone != ''">#{gfoffphone},</if>
            <if test="gfaddress != null  and gfaddress != ''">#{gfaddress},</if>
            <if test="grandmothername != null  and grandmothername != ''">#{grandmothername},</if>
            <if test="gmgx != null  and gmgx != ''">#{gmgx},</if>
            <if test="gmphone != null  and gmphone != ''">#{gmphone},</if>
            <if test="gmaddress != null  and gmaddress != ''">#{gmaddress},</if>
            <if test="gmoffphone != null  and gmoffphone != ''">#{gmoffphone},</if>
            <if test="createTime != null ">#{createTime},</if>
        </trim>
    </insert>

    <update id="updateByChildContactpeople" parameterType="ByChildContactpeople">
        update by_child_contactpeople
        <trim prefix="SET" suffixOverrides=",">
            <if test="childid != null ">childid = #{childid},</if>
            <if test="fathername != null  and fathername != ''">fathername = #{fathername},</if>
            <if test="fphone != null  and fphone != ''">fphone = #{fphone},</if>
            <if test="foffphone != null  and foffphone != ''">foffphone = #{foffphone},</if>
            <if test="mothername != null  and mothername != ''">mothername = #{mothername},</if>
            <if test="mphone != null  and mphone != ''">mphone = #{mphone},</if>
            <if test="moffphone != null  and moffphone != ''">moffphone = #{moffphone},</if>
            <if test="grandfathername != null  and grandfathername != ''">grandfathername = #{grandfathername},</if>
            <if test="gfgx != null  and gfgx != ''">gfgx = #{gfgx},</if>
            <if test="gfphone != null  and gfphone != ''">gfphone = #{gfphone},</if>
            <if test="gfoffphone != null  and gfoffphone != ''">gfoffphone = #{gfoffphone},</if>
            <if test="gfaddress != null  and gfaddress != ''">gfaddress = #{gfaddress},</if>
            <if test="grandmothername != null  and grandmothername != ''">grandmothername = #{grandmothername},</if>
            <if test="gmgx != null  and gmgx != ''">gmgx = #{gmgx},</if>
            <if test="gmphone != null  and gmphone != ''">gmphone = #{gmphone},</if>
            <if test="gmaddress != null  and gmaddress != ''">gmaddress = #{gmaddress},</if>
            <if test="gmoffphone != null  and gmoffphone != ''">gmoffphone = #{gmoffphone},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
        </trim>
        where id = #{id} or childid = #{childid}
    </update>

    <delete id="deleteByChildContactpeopleById" parameterType="Long">
        delete from by_child_contactpeople where id = #{id}
    </delete>

    <delete id="deleteByChildContactpeopleByIds" parameterType="String">
        delete from by_child_contactpeople where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <delete id="deleteByChildContactpeopleByChildIds" parameterType="String">
        delete from by_child_contactpeople where childid in
        <foreach item="childid" collection="array" open="(" separator="," close=")">
            #{childid}
        </foreach>
    </delete>

</mapper>