feat: bug-1369 工服模块,服务报告里上传报告,以及派工结案时上传附件报告时,限制上传文件在1G以内,并增加上传进度
This commit is contained in:
parent
8d3a43d152
commit
f68b70dc3d
|
|
@ -23,6 +23,7 @@ import javax.validation.Valid;
|
|||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
|
@ -36,14 +37,9 @@ import java.util.Objects;
|
|||
@RequestMapping("/file")
|
||||
public class FileController extends ControllerBase {
|
||||
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
@Resource
|
||||
private IGongfuFileService fileService;
|
||||
|
||||
@Resource
|
||||
private FileUploadService fileUploadService;
|
||||
|
||||
/**
|
||||
* 文件搜索
|
||||
*/
|
||||
|
|
@ -59,35 +55,24 @@ public class FileController extends ControllerBase {
|
|||
|
||||
/**
|
||||
* 文件上传
|
||||
* @param type 类型,1:服务月报
|
||||
* @param type 类型,1:服务月报
|
||||
* @param fileName 文件名称
|
||||
* @param file 文件
|
||||
* @param fileUrl 文件地址
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public ApiResult<Void> upload(@RequestParam Integer type,@RequestParam String fileName,@RequestParam MultipartFile file) throws IOException {
|
||||
String url = fileUploadService.upload(buildFilePath(getFileType(file.getOriginalFilename())), file);
|
||||
public ApiResult<Void> upload(@RequestParam Integer type, @RequestParam String fileName, @RequestParam String fileUrl) throws IOException {
|
||||
fileService.save(
|
||||
new GongfuFile()
|
||||
.setType(type)
|
||||
.setFileName(fileName)
|
||||
.setFileSize(file.getSize())
|
||||
.setFileSuffix(FilenameUtils.getExtension(file.getOriginalFilename()))
|
||||
.setFileUrl(url)
|
||||
.setFileSuffix(FilenameUtils.getExtension(new URL(fileUrl).getPath()))
|
||||
.setFileUrl(fileUrl)
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
private String buildFilePath(String fileType) {
|
||||
return StrUtil.format("gongfu/{}/{}/{}/{}{}", LocalDateTime.now().format(FORMATTER), AdminUserUtil.getUserId()
|
||||
, RandomUtil.randomString(4), IdUtil.fastUUID(), fileType);
|
||||
}
|
||||
|
||||
private String getFileType(String fileName) {
|
||||
return "." + FilenameUtils.getExtension(fileName).toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件删除
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue