package com.fzzy.igds.sys.pr;
|
|
import com.bstek.dorado.uploader.UploadFile;
|
import com.bstek.dorado.uploader.annotation.FileResolver;
|
import com.fzzy.igds.file.FileService;
|
import com.fzzy.igds.util.ContextUtil;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Component;
|
import javax.annotation.Resource;
|
import java.io.File;
|
import java.io.IOException;
|
import java.util.Map;
|
|
/**
|
* @Description Dorado7 附件上传公共管理层
|
* @Author CZT
|
* @Date 2024/12/28 10:05
|
*/
|
@Slf4j
|
@Component
|
public class FileUploadManage {
|
|
@Resource
|
private FileService fileService;
|
|
|
/**
|
* 上传库区简介视频
|
* fileUploadManage#videoFile
|
*
|
* @param file
|
* @param parameter
|
* @return
|
*/
|
@FileResolver
|
public String videoFile(UploadFile file, Map<String, Object> parameter) {
|
|
String fileId = null;
|
try {
|
|
String basePath = fileService.getDeptFilePath(null);
|
fileId = "aerial-" + ContextUtil.subDeptId(null)
|
+ file.getFileName().substring(
|
file.getFileName().lastIndexOf("."));
|
|
file.transferTo(new File(basePath + fileId));
|
|
} catch (IllegalStateException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
|
return fileId;
|
}
|
|
/**
|
* 上传库区鸟瞰图
|
* fileUploadManage#imgFile
|
*
|
* @param file
|
* @param parameter
|
* @return
|
*/
|
@FileResolver
|
public String imgFile(UploadFile file, Map<String, Object> parameter) {
|
|
String fileId = null;
|
try {
|
|
String basePath = fileService.getDeptFilePath(null);
|
|
fileId = "aerial-" + ContextUtil.subDeptId(null)
|
+ file.getFileName().substring(
|
file.getFileName().lastIndexOf("."));
|
|
file.transferTo(new File(basePath + fileId));
|
|
} catch (IllegalStateException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
|
return fileId;
|
}
|
|
}
|