<?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.srs.comprehensive.mapper.SrsKnrdTimeMapper">
    
    <resultMap type="SrsKnrdTime" id="SrsKnrdTimeResult">
        <result property="id"    column="id"    />
        <result property="stuNo"    column="stu_no"    />
        <result property="stuTime"    column="stu_time"    />
        <result property="fdyTime"    column="fdy_time"    />
        <result property="xsjTime"    column="xsj_time"    />
        <result property="deptTime"    column="dept_time"    />
        <result property="stuYearId"    column="stu_year_id"    />
        <result property="term"    column="term"    />
        <result property="stuYearName"    column="stu_year_name"    />
        <result property="deptName"    column="dept_name"    />
        <result property="stuName"    column="stu_name"    />
    </resultMap>

    <sql id="selectSrsKnrdTimeVo">
        select a.id, a.stu_no, a.stu_time, a.fdy_time, a.xsj_time, a.dept_time, a.stu_year_id, a.term,b.stu_name,b.dept_name,c.stu_year_name
        from srs_knrd_time as a
        left join view_stu_info as b on a.stu_no = b.stu_no
        left join srs_stu_year as c on a.stu_year_id = c.id
    </sql>

    <select id="selectSrsKnrdTimeList" parameterType="SrsKnrdTime" resultMap="SrsKnrdTimeResult">
        <include refid="selectSrsKnrdTimeVo"/>
        <where>  
            <if test="stuNo != null  and stuNo != ''"> and a.stu_no = #{stuNo}</if>
            <if test="stuTime != null "> and a.stu_time = #{stuTime}</if>
            <if test="fdyTime != null "> and a.fdy_time = #{fdyTime}</if>
            <if test="xsjTime != null "> and a.xsj_time = #{xsjTime}</if>
            <if test="deptTime != null "> and a.dept_time = #{deptTime}</if>
            <if test="stuYearId != null "> and a.stu_year_id = #{stuYearId}</if>
            <if test="term != null  and term != ''"> and a.term = #{term}</if>
        </where>
    </select>
    
    <select id="selectSrsKnrdTimeById" parameterType="Long" resultMap="SrsKnrdTimeResult">
        <include refid="selectSrsKnrdTimeVo"/>
        where a.id = #{id}
    </select>
        
    <insert id="insertSrsKnrdTime" parameterType="SrsKnrdTime" useGeneratedKeys="true" keyProperty="id">
        insert into srs_knrd_time
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stuNo != null">stu_no,</if>
            <if test="stuTime != null">stu_time,</if>
            <if test="fdyTime != null">fdy_time,</if>
            <if test="xsjTime != null">xsj_time,</if>
            <if test="deptTime != null">dept_time,</if>
            <if test="stuYearId != null">stu_year_id,</if>
            <if test="term != null">term,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stuNo != null">#{stuNo},</if>
            <if test="stuTime != null">#{stuTime},</if>
            <if test="fdyTime != null">#{fdyTime},</if>
            <if test="xsjTime != null">#{xsjTime},</if>
            <if test="deptTime != null">#{deptTime},</if>
            <if test="stuYearId != null">#{stuYearId},</if>
            <if test="term != null">#{term},</if>
         </trim>
    </insert>

    <update id="updateSrsKnrdTime" parameterType="SrsKnrdTime">
        update srs_knrd_time
        <trim prefix="SET" suffixOverrides=",">
            <if test="stuNo != null">stu_no = #{stuNo},</if>
            <if test="stuTime != null">stu_time = #{stuTime},</if>
            <if test="fdyTime != null">fdy_time = #{fdyTime},</if>
            <if test="xsjTime != null">xsj_time = #{xsjTime},</if>
            <if test="deptTime != null">dept_time = #{deptTime},</if>
            <if test="stuYearId != null">stu_year_id = #{stuYearId},</if>
            <if test="term != null">term = #{term},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSrsKnrdTimeById" parameterType="Long">
        delete from srs_knrd_time where id = #{id}
    </delete>

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