<?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.salpa.subject.mapper.ProjectSyncTaskMapper">

    <resultMap type="com.salpa.subject.domain.MonitorProjectSyncTask" id="MonitorProjectSyncTaskResult">
        <id     property="id"            column="id"             />
        <id     property="projectId"            column="project_id"             />
        <result property="userId"          column="user_id"           />
        <result property="status"   column="status"    />
        <result property="runAt"              column="run_at"                />
        <result property="result"             column="result"              />
        <result property="updateAt"             column="update_at"              />
        <result property="createAt"             column="create_at"              />
    </resultMap>

    <select id="listNewTasks" resultMap="MonitorProjectSyncTaskResult">
        SELECT id,project_id,user_id,status,run_at,result
        FROM monitor_project_sync_task WHERE status = "NEW"
        ORDER BY id
        limit #{size}
    </select>

    <update id="updateStatusAndResultById">
        UPDATE monitor_project_sync_task SET status = #{status},result = #{result},run_at = sysdate()
        WHERE id = #{taskId}
    </update>
</mapper>