<?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.cirs.biz.mapper.TVerificationTaskMapper">
    
    <resultMap type="TVerificationTask" id="TVerificationTaskResult">
        <result property="id"    column="id"    />
        <result property="taskName"    column="task_name"    />
        <result property="taskStatus"    column="task_status"    />
        <result property="subtaskNum"    column="subtask_num"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="progress"    column="progress"    />
        <result property="accuracyRate"    column="accuracy_rate"    />
        <result property="recallRate"    column="recall_rate"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTVerificationTaskVo">
        select id, task_name, task_status, subtask_num, start_time, end_time, progress, accuracy_rate, recall_rate, create_by, create_time, update_by, update_time, remark from t_verification_task
    </sql>

    <select id="selectTVerificationTaskList" parameterType="TVerificationTask" resultMap="TVerificationTaskResult">
        <include refid="selectTVerificationTaskVo"/>
        <where>  
            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
            <if test="taskStatus != null  and taskStatus != ''"> and task_status = #{taskStatus}</if>
            <if test="subtaskNum != null "> and subtask_num = #{subtaskNum}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="progress != null "> and progress = #{progress}</if>
            <if test="accuracyRate != null  and accuracyRate != ''"> and accuracy_rate = #{accuracyRate}</if>
            <if test="recallRate != null  and recallRate != ''"> and recall_rate = #{recallRate}</if>
        </where>
    </select>
    
    <select id="selectTVerificationTaskById" parameterType="Long" resultMap="TVerificationTaskResult">
        <include refid="selectTVerificationTaskVo"/>
        where id = #{id}
    </select>
    <select id="getLastTask" resultMap="TVerificationTaskResult">
        select * from t_verification_task order by id desc limit 1
    </select>

    <insert id="insertTVerificationTask" parameterType="TVerificationTask" useGeneratedKeys="true" keyProperty="id">
        insert into t_verification_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskName != null">task_name,</if>
            <if test="taskStatus != null">task_status,</if>
            <if test="subtaskNum != null">subtask_num,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="progress != null">progress,</if>
            <if test="accuracyRate != null">accuracy_rate,</if>
            <if test="recallRate != null">recall_rate,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskName != null">#{taskName},</if>
            <if test="taskStatus != null">#{taskStatus},</if>
            <if test="subtaskNum != null">#{subtaskNum},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="progress != null">#{progress},</if>
            <if test="accuracyRate != null">#{accuracyRate},</if>
            <if test="recallRate != null">#{recallRate},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>


    <update id="updateTVerificationTask" parameterType="TVerificationTask">
        update t_verification_task
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="taskStatus != null">task_status = #{taskStatus},</if>
            <if test="subtaskNum != null">subtask_num = #{subtaskNum},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="progress != null">progress = #{progress},</if>
            <if test="accuracyRate != null">accuracy_rate = #{accuracyRate},</if>
            <if test="recallRate != null">recall_rate = #{recallRate},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTVerificationTaskById" parameterType="Long">
        delete from t_verification_task where id = #{id}
    </delete>

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