<?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.qmth.sop.business.mapper.TBTaskMapper">

    <select id="query" resultType="com.qmth.sop.business.bean.result.TaskListResult">
        select
        tbt.id,
        tbt.`type`,
        tbt.status,
        tbt.`result`,
        tbt.create_time as createTime,
        tbt.create_id as createId,
        su.real_name as createName,
        if(ISNULL(tbt.import_file_path),false,true) as hasImportFile,
        if(ISNULL(tbt.result_file_path),false,true) as hasResultFile,
        if(ISNULL(tbt.report_file_path),false,true) as hasReportFile
        from t_b_task tbt
        left join sys_user su on su.id = tbt.create_id
        <where>
            <if test="status != null and status != ''">
                and tbt.status = #{status}
            </if>
            <if test="type != null and type != ''">
                and tbt.type = #{type}
            </if>
            <if test="result != null and result != ''">
                and tbt.result = #{result}
            </if>
        </where>
        order by tbt.update_time desc
    </select>
</mapper>
