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

    <resultMap type="BySchoolcalendarClass" id="BySchoolcalendarClassResult">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="type" column="type"/>
        <result property="classid" column="classid"/>
        <result property="xnxq" column="xnxq"/>
        <result property="deptid" column="deptId"/>
        <result property="activitytime" column="activitytime"/>
        <result property="activityendtime" column="activityendtime"/>
        <result property="stylecolor" column="stylecolor"/>
        <result property="createuserid" column="createuserid"/>
        <result property="createtime" column="createtime"/>
        <association property="byClass" column="bjbh" javaType="ByClass" resultMap="ByClassResult"/>
    </resultMap>

    <resultMap type="ByClass" id="ByClassResult">
        <result property="bjbh" column="bjbh"/>
        <result property="deptId" column="dept_id"/>
        <result property="bjtype" column="bjtype"/>
        <result property="bhxh" column="bhxh"/>
        <result property="xn" column="xn"/>
        <result property="bjmc" column="bjmc"/>
        <result property="bjrych" column="bjrych"/>
        <result property="jbny" column="jbny"/>
        <result property="zbjs" column="zbjs"/>
        <result property="zbjsxm" column="zbjsxm"/>
        <result property="pbjs" column="pbjs"/>
        <result property="pbjsxm" column="pbjsxm"/>
        <result property="zljs" column="zljs"/>
        <result property="zljsxm" column="zljsxm"/>
        <result property="isdel" column="isdel"/>
        <result property="createtime" column="createtime"/>
    </resultMap>

    <sql id="selectBySchoolcalendarClassVo">
        select s.id, s.name, s.type, s.classid, s.xnxq, s.deptId, s.activitytime, s.activityendtime, s.stylecolor, s.createuserid, s.createtime,
               c.bjmc
        from by_schoolcalendar_class s, by_class c
    </sql>

    <select id="selectBySchoolcalendarClassList" parameterType="BySchoolcalendarClass"
            resultMap="BySchoolcalendarClassResult">
        <include refid="selectBySchoolcalendarClassVo"/>
        where s.classid=c.bjbh

        <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
        <if test="type != null  and type != ''">and type = #{type}</if>
        <if test="classid != null  and classid != ''">and classid = #{classid}</if>
        <if test="xnxq != null  and xnxq != ''">and xnxq = #{xnxq}</if>
        <if test="deptid != null ">and deptId = #{deptid}</if>
        <if test="activitytime != null ">and activitytime = #{activitytime}</if>
        <if test="activityendtime != null ">and activityendtime = #{activityendtime}</if>
        <if test="stylecolor != null  and stylecolor != ''">and stylecolor = #{stylecolor}</if>
        <if test="createuserid != null ">and createuserid = #{createuserid}</if>
        <if test="createtime != null ">and createtime = #{createtime}</if>

    </select>

    <select id="selectBySchoolcalendarClassById" parameterType="Long" resultMap="BySchoolcalendarClassResult">
        <include refid="selectBySchoolcalendarClassVo"/>
        where id = #{id}
    </select>

    <insert id="insertBySchoolcalendarClass" parameterType="BySchoolcalendarClass">
        insert into by_schoolcalendar_class
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null ">id,</if>
            <if test="name != null  and name != ''">name,</if>
            <if test="type != null  and type != ''">type,</if>
            <if test="classid != null  and classid != ''">classid,</if>
            <if test="xnxq != null  and xnxq != ''">xnxq,</if>
            <if test="deptid != null ">deptId,</if>
            <if test="activitytime != null ">activitytime,</if>
            <if test="activityendtime != null ">activityendtime,</if>
            <if test="stylecolor != null  and stylecolor != ''">stylecolor,</if>
            <if test="createuserid != null ">createuserid,</if>
            <if test="createtime != null ">createtime,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null ">#{id},</if>
            <if test="name != null  and name != ''">#{name},</if>
            <if test="type != null  and type != ''">#{type},</if>
            <if test="classid != null  and classid != ''">#{classid},</if>
            <if test="xnxq != null  and xnxq != ''">#{xnxq},</if>
            <if test="deptid != null ">#{deptid},</if>
            <if test="activitytime != null ">#{activitytime},</if>
            <if test="activityendtime != null ">#{activityendtime},</if>
            <if test="stylecolor != null  and stylecolor != ''">#{stylecolor},</if>
            <if test="createuserid != null ">#{createuserid},</if>
            <if test="createtime != null ">#{createtime},</if>
        </trim>
    </insert>

    <update id="updateBySchoolcalendarClass" parameterType="BySchoolcalendarClass">
        update by_schoolcalendar_class
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null  and name != ''">name = #{name},</if>
            <if test="type != null  and type != ''">type = #{type},</if>
            <if test="classid != null  and classid != ''">classid = #{classid},</if>
            <if test="xnxq != null  and xnxq != ''">xnxq = #{xnxq},</if>
            <if test="deptid != null ">deptId = #{deptid},</if>
            <if test="activitytime != null ">activitytime = #{activitytime},</if>
            <if test="activityendtime != null ">activityendtime = #{activityendtime},</if>
            <if test="stylecolor != null  and stylecolor != ''">stylecolor = #{stylecolor},</if>
            <if test="createuserid != null ">createuserid = #{createuserid},</if>
            <if test="createtime != null ">createtime = #{createtime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBySchoolcalendarClassById" parameterType="Long">
        delete from by_schoolcalendar_class where id = #{id}
    </delete>

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

</mapper>
