<?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.yami.shop.dao.ExportTaskMapper">

    <select id="findByUserIdAndStatusAndType" resultType="com.yami.shop.bean.model.ExportTask">
        select * from tz_export_task where  user_id = #{userId} and export_type =#{exportType} and export_status = #{exportStatus} order by  create_time limit 1
    </select>

    <select id="findByUserIdAndId" resultType="com.yami.shop.bean.model.ExportTask">
        select * from tz_export_task
            <where>
                <if test="userId != null ">
                    AND  user_id = #{userId}
                </if>
                <if test="id != null  and id != ''">
                    AND  id = #{id}
                </if>
            </where>
    </select>

    <select id="findPage" resultType="com.yami.shop.bean.vo.ExportTaskVo">
        select a.id,a.user_id,a.export_type,a.export_msg,a.export_status,a.task_name,a.create_time,a.update_time,b.username as operator  from tz_export_task a
        left join  tz_sys_user b on a.user_id =b.user_id
        <where>
            <if test="userId != null ">
                AND  a.user_id = #{userId}
            </if>
            <if test="exportType != null ">
                AND  a.export_type = #{exportType}
            </if>
        </where>
        order by  a.create_time desc
    </select>
</mapper>
