<?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="cn.reghao.tnb.file.app.zjob.db.JobDetailMapper">
    <insert id="save">
        insert into file_job_detail
        (`job_id`,`job_name`,`status`,`start_at`,`end_at`)
        values
        (#{jobId},#{jobName},#{status},#{startAt},#{endAt})
    </insert>
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert into file_job_detail
        (`job_id`,`job_name`,`status`,`start_at`,`end_at`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.jobId},#{item.jobName},#{item.status},#{item.startAt},#{item.endAt})
        </foreach>
    </insert>

    <update id="updateSetEnd">
        update file_job_detail
        set `status`=#{status},end_at=#{endAt}
        where job_id=#{jobId}
    </update>

    <select id="findAll" resultType="cn.reghao.tnb.file.app.zjob.model.po.JobDetail">
        select *
        from file_job_detail
    </select>
    <select id="findByStatus" resultType="cn.reghao.tnb.file.app.zjob.model.po.JobDetail">
        select *
        from file_job_detail
        where `status`=#{status}
        limit 1000
    </select>
</mapper>
