<?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.zg.project.wisdom.mapper.WcsTaskResultMapper">

    <resultMap id="WcsTaskResultResultMap" type="com.zg.project.wisdom.domain.WcsTaskResult">
        <result property="id"           column="id"/>
        <result property="taskId"    column="task_id"/>
        <result property="taskStatus"       column="task_status"/>
        <result property="msg"          column="msg"/>
        <result property="jobId"        column="job_id"/>
        <result property="owner"        column="owner"/>
        <result property="type"         column="type"/>
        <result property="priority"     column="priority"/>
        <result property="sourceName"   column="source_name"/>
        <result property="targetName"   column="target_name"/>
        <result property="createTime"   column="create_time"/>
        <result property="updateTime"   column="update_time"/>
        <result property="isDelete"     column="is_delete"/>
        <result property="createBy"     column="create_by"/>
        <result property="updateBy"     column="update_by"/>
    </resultMap>

    <insert id="insertWcsTaskResult" parameterType="com.zg.project.wisdom.domain.WcsTaskResult" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO wcs_task_result
        (
            task_id,
            task_status,
            msg,
            create_time,
            is_delete,
            create_by
        )
        VALUES
            (
                #{taskId},
                #{taskStatus},
                #{msg},
                #{createTime},
                #{isDelete},
                #{createBy}
            )
    </insert>

    <select id="countByTaskId" resultType="java.lang.Integer" parameterType="java.lang.String">
        SELECT COUNT(*)
        FROM wcs_task_result
        WHERE task_id = #{taskId}
          AND task_status = '1'
    </select>

</mapper>
