<?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.CphStuEvaTaskMapper">
    
    <resultMap type="CphStuEvaTask" id="CphStuEvaTaskResult">
        <result property="id"    column="id"    />
        <result property="taskTNo"    column="task_t_no"    />
        <result property="status"    column="status"    />
        <result property="startTime"    column="start_time"    />
        <result property="taskName"    column="task_name"    />
        <result property="stuYearId"    column="stu_year_id"    />
    </resultMap>

    <sql id="selectCphStuEvaTaskVo">
        select id, task_t_no, status, start_time, task_name, stu_year_id from cph_stu_eva_task
    </sql>

    <select id="selectCphStuEvaTaskList" parameterType="CphStuEvaTask" resultMap="CphStuEvaTaskResult">
        <include refid="selectCphStuEvaTaskVo"/>
        <where>  
            <if test="taskTNo != null  and taskTNo != ''"> and task_t_no = #{taskTNo}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
            <if test="stuYearId != null "> and stu_year_id = #{stuYearId}</if>
        </where>
    </select>
    
    <select id="selectCphStuEvaTaskById" parameterType="Long" resultMap="CphStuEvaTaskResult">
        <include refid="selectCphStuEvaTaskVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCphStuEvaTask" parameterType="CphStuEvaTask" useGeneratedKeys="true" keyProperty="id">
        insert into cph_stu_eva_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskTNo != null">task_t_no,</if>
            <if test="status != null">status,</if>
            <if test="startTime != null">start_time,</if>
            <if test="taskName != null">task_name,</if>
            <if test="stuYearId != null">stu_year_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskTNo != null">#{taskTNo},</if>
            <if test="status != null">#{status},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="taskName != null">#{taskName},</if>
            <if test="stuYearId != null">#{stuYearId},</if>
         </trim>
    </insert>

    <update id="updateCphStuEvaTask" parameterType="CphStuEvaTask">
        update cph_stu_eva_task
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskTNo != null">task_t_no = #{taskTNo},</if>
            <if test="status != null">status = #{status},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="stuYearId != null">stu_year_id = #{stuYearId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCphStuEvaTaskById" parameterType="Long">
        delete from cph_stu_eva_task where id = #{id}
    </delete>

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