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

    <resultMap type="ByTeacherassessment" id="ByTeacherassessmentResult">
        <result property="id" column="id"/>
        <result property="jsid" column="jsid"/>
        <result property="classid" column="classid"/>
        <result property="deptId" column="dept_id"/>
        <result property="month" column="month"/>
        <result property="yrlcbl" column="yrlcbl"/>
        <result property="jskqbl" column="jskqbl"/>
        <result property="yekqbl" column="yekqbl"/>
        <result property="sgbl" column="sgbl"/>
        <result property="wsbl" column="wsbl"/>
        <result property="zfbl" column="zfbl"/>
        <result property="createTime" column="create_time"/>
        <association property="sysUser" column="jsid" javaType="SysUser" resultMap="SysUserResult"/>
    </resultMap>

    <resultMap type="SysUser" id="SysUserResult">
        <id property="userId" column="user_id"/>
        <result property="userName" column="user_name"/>
        <result property="nickName" column="nick_name"/>
    </resultMap>

    <sql id="selectByTeacherassessmentVo">
        select a.id, a.jsid, a.classid, a.dept_id, a.month, a.yrlcbl, a.jskqbl, a.yekqbl, a.sgbl, a.wsbl, a.zfbl, a.create_time,b.nick_name from by_teacherassessment a
        left join sys_user b on a.jsid=b.user_id
    </sql>

    <select id="selectByTeacherassessmentList" parameterType="ByTeacherassessment"
            resultMap="ByTeacherassessmentResult">
        <include refid="selectByTeacherassessmentVo"/>
        <where>
            <if test="jsid != null ">and a.jsid = #{jsid}</if>
            <if test="classid != null  and classid != ''">and a.classid = #{classid}</if>
            <if test="deptId != null ">and a.dept_id = #{deptId}</if>
            <if test="month != null  and month != ''">and a.month = #{month}</if>
            <if test="yrlcbl != null ">and a.yrlcbl = #{yrlcbl}</if>
            <if test="jskqbl != null ">and a.jskqbl = #{jskqbl}</if>
            <if test="yekqbl != null ">and a.yekqbl = #{yekqbl}</if>
            <if test="sgbl != null ">and a.sgbl = #{sgbl}</if>
            <if test="wsbl != null ">and a.wsbl = #{wsbl}</if>
            <if test="zfbl != null ">and a.zfbl = #{zfbl}</if>
        </where>
        <!-- 数据范围过滤 -->
        ${dataScope}
        order by a.create_time desc
    </select>

    <select id="selectByTeacherassessmentById" parameterType="Long" resultMap="ByTeacherassessmentResult">
        <include refid="selectByTeacherassessmentVo"/>
        where a.id = #{id}
    </select>

    <insert id="insertByTeacherassessment" parameterType="ByTeacherassessment" useGeneratedKeys="true" keyProperty="id">
        insert into by_teacherassessment
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jsid != null ">jsid,</if>
            <if test="classid != null  and classid != ''">classid,</if>
            <if test="deptId != null ">dept_id,</if>
            <if test="month != null  and month != ''">month,</if>
            <if test="yrlcbl != null ">yrlcbl,</if>
            <if test="jskqbl != null ">jskqbl,</if>
            <if test="yekqbl != null ">yekqbl,</if>
            <if test="sgbl != null ">sgbl,</if>
            <if test="wsbl != null ">wsbl,</if>
            <if test="zfbl != null ">zfbl,</if>
            <if test="createTime != null ">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="jsid != null ">#{jsid},</if>
            <if test="classid != null  and classid != ''">#{classid},</if>
            <if test="deptId != null ">#{deptId},</if>
            <if test="month != null  and month != ''">#{month},</if>
            <if test="yrlcbl != null ">#{yrlcbl},</if>
            <if test="jskqbl != null ">#{jskqbl},</if>
            <if test="yekqbl != null ">#{yekqbl},</if>
            <if test="sgbl != null ">#{sgbl},</if>
            <if test="wsbl != null ">#{wsbl},</if>
            <if test="zfbl != null ">#{zfbl},</if>
            <if test="createTime != null ">#{createTime},</if>
        </trim>
    </insert>

    <update id="updateByTeacherassessment" parameterType="ByTeacherassessment">
        update by_teacherassessment
        <trim prefix="SET" suffixOverrides=",">
            <if test="jsid != null ">jsid = #{jsid},</if>
            <if test="classid != null  and classid != ''">classid = #{classid},</if>
            <if test="deptId != null ">dept_id = #{deptId},</if>
            <if test="month != null  and month != ''">month = #{month},</if>
            <if test="yrlcbl != null ">yrlcbl = #{yrlcbl},</if>
            <if test="jskqbl != null ">jskqbl = #{jskqbl},</if>
            <if test="yekqbl != null ">yekqbl = #{yekqbl},</if>
            <if test="sgbl != null ">sgbl = #{sgbl},</if>
            <if test="wsbl != null ">wsbl = #{wsbl},</if>
            <if test="zfbl != null ">zfbl = #{zfbl},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteByTeacherassessmentById" parameterType="Long">
        delete from by_teacherassessment where id = #{id}
    </delete>

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

</mapper>