<?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.ByFamilyeduMapper">

    <resultMap type="ByFamilyedu" id="ByFamilyeduResult">
        <result property="id" column="id"/>
        <result property="parentid" column="parentid"/>
        <result property="title" column="title"/>
        <result property="content" column="content"/>
        <result property="sort" column="sort"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <sql id="selectByFamilyeduVo">
        select id, parentid, title, content, sort, create_time from by_familyedu
    </sql>

    <select id="selectByFamilyeduList" parameterType="ByFamilyedu" resultMap="ByFamilyeduResult">
        <include refid="selectByFamilyeduVo"/>
        <where>
            <if test="parentid != null ">and parentid = #{parentid}</if>
            <if test="title != null  and title != ''">and title = #{title}</if>
            <if test="content != null  and content != ''">and content = #{content}</if>
            <if test="sort != null ">and sort = #{sort}</if>
        </where>
    </select>

    <select id="selectByFamilyeduById" parameterType="Long" resultMap="ByFamilyeduResult">
        <include refid="selectByFamilyeduVo"/>
        where id = #{id}
    </select>

    <insert id="insertByFamilyedu" parameterType="ByFamilyedu" useGeneratedKeys="true" keyProperty="id">
        insert into by_familyedu
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="parentid != null ">parentid,</if>
            <if test="title != null  and title != ''">title,</if>
            <if test="content != null  and content != ''">content,</if>
            <if test="sort != null ">sort,</if>
            <if test="createTime != null ">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="parentid != null ">#{parentid},</if>
            <if test="title != null  and title != ''">#{title},</if>
            <if test="content != null  and content != ''">#{content},</if>
            <if test="sort != null ">#{sort},</if>
            <if test="createTime != null ">#{createTime},</if>
        </trim>
    </insert>

    <update id="updateByFamilyedu" parameterType="ByFamilyedu">
        update by_familyedu
        <trim prefix="SET" suffixOverrides=",">
            <if test="parentid != null ">parentid = #{parentid},</if>
            <if test="title != null  and title != ''">title = #{title},</if>
            <if test="content != null  and content != ''">content = #{content},</if>
            <if test="sort != null ">sort = #{sort},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteByFamilyeduById" parameterType="Long">
        delete from by_familyedu where id = #{id}
    </delete>

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

</mapper>