package com.dxhy;


import com.dxhy.oss.model.FileModel;
import com.dxhy.oss.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;

/**
 * @author user
 */
@SuppressWarnings("FieldCanBeLocal")
@Slf4j
public class OfdHandle extends Thread {

    private final File file;

    @Autowired
    private FileService fileService;

    public OfdHandle(File file) {
        this.file = file;

    }

    @Override
    public void run() {

        fileService = (FileService) SpringContextUtils.getBean("fileService");
        FileModel fileModel = new FileModel();
        try {
            fileModel = fileService.uploadFile(file.getPath(), file.getPath());
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("文件上传返回结果:" + fileModel.getCode() + "  " + fileModel.getFilePath());
    }
}
