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

    <resultMap type="SrsZxjTime" id="SrsZxjTimeResult">
        <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"/>
    </resultMap>

    <sql id="selectSrsZxjTimeVo">
        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_zxj_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="selectSrsZxjTimeList" parameterType="SrsZxjTime" resultMap="SrsZxjTimeResult">
        <include refid="selectSrsZxjTimeVo"/>
        <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="selectSrsZxjTimeById" parameterType="Long" resultMap="SrsZxjTimeResult">
        <include refid="selectSrsZxjTimeVo"/>
        where a.id = #{id}
    </select>

    <insert id="insertSrsZxjTime" parameterType="SrsZxjTime" useGeneratedKeys="true" keyProperty="id">
        insert into srs_zxj_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="updateSrsZxjTime" parameterType="SrsZxjTime">
        update srs_zxj_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="deleteSrsZxjTimeById" parameterType="Long">
        delete
        from srs_zxj_time
        where id = #{id}
    </delete>

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