package com.infoepoch.pms.dispatchassistant.domain.system.uploadFile;

import com.infoepoch.pms.dispatchassistant.common.constant.StoreKeys;
import com.infoepoch.pms.dispatchassistant.common.utils.DateTool;
import com.infoepoch.pms.dispatchassistant.common.utils.ListUtils;
import com.infoepoch.pms.dispatchassistant.domain.basic.store.KeyValueStoreService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ValidationException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

/**
 * 上传文件Service
 *
 * @author pengh
 */
@Service
public class UploadFileService {

    @Autowired
    IUploadFileRepository uploadFileRepository;

    @Autowired
    KeyValueStoreService keyValueStoreService;


    private  static    List<String> extendList=null;

    /**
     * 取拓展名白名单
     *
     * @return
     */
    private  List<String> getExtendList() {
        if (extendList == null) {
            String exs = keyValueStoreService.queryValueByKey("extendList");
            if (StringUtils.isNotBlank(exs))
                extendList = ListUtils.splitString(exs, ",");
        }

        return extendList;
    }

}
