<?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.bonus.canteen.core.common.export.mapper.ExportRecordMapper">

    <select id="listByParam" resultType="com.bonus.canteen.core.common.export.model.ExportRecord">
        SELECT
            export_id, file_name, file_url, file_size, export_file_state, export_file_type, `process`, if_private, finish_time, expired_time, crby, crtime, upby, uptime
        FROM export_record
        WHERE 1=1
        <if test="param.fileName != null and param.fileName != ''">
            AND file_name like #{param.fileName}
        </if>
        <if test="param.exportFileType != null and param.exportFileType != ''">
            AND export_file_type = #{param.exportFileType}
        </if>
        <if test="param.exportFileState != null">
            AND export_file_state = #{param.exportFileState}
        </if>
        <if test="param.userId != null and param.userId != ''">
            AND (crby = #{param.userId} OR if_private = 2)
        </if>
        ORDER BY export_id DESC
    </select>
</mapper>
