package com.sunxung.factoring.service.sys.impl;

import java.io.File;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sunxung.factoring.component.annotation.CsvConstants;
import com.sunxung.factoring.component.exception.BusinessException;
import com.sunxung.factoring.component.util.CodeUtil;
import com.sunxung.factoring.component.util.StringUtil;
import com.sunxung.factoring.dict.impl.FileModuleDict;
import com.sunxung.factoring.service.sys.CsvHelpService;
import com.sunxung.factoring.service.sys.FileStorageService;

/**
 * @className:CSVHelpService
 * @description:CSV导入导出帮助类service实现类
 * @author:杜小姣
 * @e-mail:1261237207@qq.com
 * @date:2018年3月17日 下午2:59:17
 */
@Service
public class CsvHelpServiceImpl implements CsvHelpService {

    @Autowired
    private FileStorageService fileStorageService;

    @Override
    public List<String> importCSV(HttpServletRequest request) {
        List<String> dataList = null;
//        try {
//            // 得到的是相对路径
//            String savePath = fileStorageService.getAbsoluteFilePath(request, FileModuleDict.ChildEnum.OTHER);
//            if (StringUtil.isEmpty(savePath)) {
//                throw new BusinessException(CodeUtil.IMPORT_DATA_ERROR, CsvConstants.NULL_FILE_MSG);
//            }
//            File file = new File(savePath);
//            if (!file.getName().endsWith(CsvConstants.CSV_TYPE)) {
//                throw new BusinessException(CodeUtil.IMPORT_DATA_ERROR, CsvConstants.UNSUPPORT_FILE_TYPE_MSG);
//            }
            return dataList;
//        } catch (Exception e) {
//            throw new BusinessException(CodeUtil.FAIL, e.getMessage());
//        }
    }
}
