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

    <resultMap type="ByThemeWeekplan" id="ByThemeWeekplanResult">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="schoolid" column="schoolid"/>
        <result property="classid" column="classid"/>
        <result property="month" column="month"/>
        <result property="zc" column="zc"/>
        <result property="remark" column="remark"/>
        <result property="status" column="status"/>
        <result property="spr" column="spr"/>
        <result property="sptime" column="sptime"/>
        <result property="shyj" column="shyj"/>
        <result property="createuserid" column="createuserid"/>
        <result property="createTime" column="create_time"/>
        <result property="xnxq" column="xnxq"/>
    </resultMap>

    <sql id="selectByThemeWeekplanVo">
        select id, name, schoolid, classid, month, zc, remark, status, spr, sptime, shyj, createuserid, create_time, xnxq from by_theme_weekplan
    </sql>

    <select id="selectByThemeWeekplanList" parameterType="ByThemeWeekplan" resultMap="ByThemeWeekplanResult">
        <include refid="selectByThemeWeekplanVo"/>
        <where>
            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
            <if test="schoolid != null ">and schoolid = #{schoolid}</if>
            <if test="classid != null  and classid != ''">and classid = #{classid}</if>
            <if test="month != null ">and month = #{month}</if>
            <if test="zc != null ">and zc = #{zc}</if>
            <if test="status != null  and status != ''">and status = #{status}</if>
            <if test="spr != null ">and spr = #{spr}</if>
            <if test="sptime != null ">and sptime = #{sptime}</if>
            <if test="shyj != null  and shyj != ''">and shyj = #{shyj}</if>
            <if test="createuserid != null ">and createuserid = #{createuserid}</if>
            <if test="xnxq != null  and xnxq != ''">and xnxq = #{xnxq}</if>
        </where>
        order by month,zc desc
    </select>

    <select id="selectByThemeWeekplanById" parameterType="String" resultMap="ByThemeWeekplanResult">
        <include refid="selectByThemeWeekplanVo"/>
        where id = #{id}
    </select>

    <insert id="insertByThemeWeekplan" parameterType="ByThemeWeekplan">
        insert into by_theme_weekplan
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">id,</if>
            <if test="name != null  and name != ''">name,</if>
            <if test="schoolid != null ">schoolid,</if>
            <if test="classid != null  and classid != ''">classid,</if>
            <if test="month != null ">month,</if>
            <if test="zc != null ">zc,</if>
            <if test="remark != null  and remark != ''">remark,</if>
            <if test="status != null  and status != ''">status,</if>
            <if test="spr != null ">spr,</if>
            <if test="sptime != null ">sptime,</if>
            <if test="shyj != null  and shyj != ''">shyj,</if>
            <if test="createuserid != null ">createuserid,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="xnxq != null  and xnxq != ''">xnxq,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">#{id},</if>
            <if test="name != null  and name != ''">#{name},</if>
            <if test="schoolid != null ">#{schoolid},</if>
            <if test="classid != null  and classid != ''">#{classid},</if>
            <if test="month != null ">#{month},</if>
            <if test="zc != null ">#{zc},</if>
            <if test="remark != null  and remark != ''">#{remark},</if>
            <if test="status != null  and status != ''">#{status},</if>
            <if test="spr != null ">#{spr},</if>
            <if test="sptime != null ">#{sptime},</if>
            <if test="shyj != null  and shyj != ''">#{shyj},</if>
            <if test="createuserid != null ">#{createuserid},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="xnxq != null  and xnxq != ''">#{xnxq},</if>
        </trim>
    </insert>

    <update id="updateByThemeWeekplan" parameterType="ByThemeWeekplan">
        update by_theme_weekplan
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null  and name != ''">name = #{name},</if>
            <if test="schoolid != null ">schoolid = #{schoolid},</if>
            <if test="classid != null  and classid != ''">classid = #{classid},</if>
            <if test="month != null ">month = #{month},</if>
            <if test="zc != null ">zc = #{zc},</if>
            <if test="remark != null  and remark != ''">remark = #{remark},</if>
            <if test="status != null  and status != ''">status = #{status},</if>
            <if test="spr != null ">spr = #{spr},</if>
            <if test="sptime != null ">sptime = #{sptime},</if>
            <if test="shyj != null  and shyj != ''">shyj = #{shyj},</if>
            <if test="createuserid != null ">createuserid = #{createuserid},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="xnxq != null  and xnxq != ''">xnxq = #{xnxq},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteByThemeWeekplanById" parameterType="String">
        delete from by_theme_weekplan where id = #{id}
    </delete>

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

</mapper>