package com.erp.dataimport.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.erp.dataimport.entity.ImportRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 导入记录 Mapper
 */
@Mapper
public interface ImportRecordRepository extends BaseMapper<ImportRecord> {

    @Select("SELECT * FROM import_record WHERE task_id = #{taskId} AND deleted_at IS NULL ORDER BY row_number ASC")
    List<ImportRecord> selectByTaskId(@Param("taskId") Long taskId);

    @Select("SELECT * FROM import_record WHERE task_id = #{taskId} AND result = 'fail' AND deleted_at IS NULL ORDER BY row_number ASC")
    List<ImportRecord> selectFailRecordsByTaskId(@Param("taskId") Long taskId);
}
