package com.qmth.paper.library;

import com.qmth.boot.tools.excel.ExcelReader;
import com.qmth.boot.tools.excel.enums.ExcelType;
import com.qmth.boot.tools.excel.model.DataMap;
import com.qmth.paper.library.business.service.PaperLibraryService;
import com.qmth.paper.library.common.entity.ExamStudent;
import com.qmth.paper.library.common.util.FileStoreUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;

/**
 * 短信工具测试类
 */
@SpringBootTest
@RunWith(SpringRunner.class)
public class ExcelReadTest {

    private static final Logger LOGGER = LoggerFactory.getLogger(ExcelReadTest.class);

    @Resource
    PaperLibraryService paperLibraryService;

    @Resource
    FileStoreUtil fileStoreUtil;

    // 根目录必须为学校ID那一层
    static String filePath = "/Users/xiaofei/Downloads/studentTemplate.xlsx";

    public static void main(String[] args) {
        File file = new File(filePath);
        try {
            ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, new FileInputStream(file), 0);
            List<DataMap> dataMapList = excelReader.getDataMapList();
            List<ExamStudent> objectList = excelReader.getObjectList(ExamStudent.class);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }


}
