<?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="io.dataease.base.mapper.ext.ExtDataSetTaskMapper">

    <resultMap id="BaseResult" type="io.dataease.dto.dataset.DataSetTaskLogDTO"
               extends="io.dataease.base.mapper.DatasetTableTaskLogMapper.BaseResultMap">
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="dataset_name" jdbcType="VARCHAR" property="datasetName"/>
    </resultMap>

    <resultMap id="TaskResult" type="io.dataease.dto.dataset.DataSetTaskDTO" extends="io.dataease.base.mapper.DatasetTableTaskMapper.BaseResultMap">
        <result column="table_name" jdbcType="VARCHAR" property="datasetName"/>
        <result column="NEXT_FIRE_TIME" jdbcType="BIGINT" property="nextExecTime"/>
    </resultMap>

    <select id="list" resultMap="BaseResult" parameterType="io.dataease.base.domain.DatasetTableTaskLog">
        SELECT dataset_table_task_log.*, dataset_table_task.name, dataset_table.name as dataset_name
        FROM dataset_table_task_log
        LEFT JOIN dataset_table_task ON dataset_table_task_log.task_id = dataset_table_task.id
        LEFT JOIN dataset_table ON dataset_table_task_log.table_id = dataset_table.id
        <if test="_parameter != null">
            <include refid="io.dataease.base.mapper.ext.query.GridSql.gridCondition" />
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        <if test="orderByClause == null">
            ORDER BY dataset_table_task_log.create_time desc
        </if>
    </select>

    <select id="taskList" resultMap="TaskResult" parameterType="io.dataease.base.mapper.ext.query.GridExample">
        SELECT dataset_table.name as table_name, dataset_table_task.* , qrtz_triggers.*
        FROM dataset_table_task
        left join dataset_table on dataset_table.id=dataset_table_task.table_id
        left join qrtz_triggers on dataset_table_task.id=qrtz_triggers.TRIGGER_NAME
        <if test="_parameter != null">
            <include refid="io.dataease.base.mapper.ext.query.GridSql.gridCondition" />
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        <if test="orderByClause == null">
            order by dataset_table_task.create_time desc
        </if>
    </select>



</mapper>
