|
@@ -5,6 +5,8 @@ import com.example.fms.common.model.dto.FMSDeleteFileDTO;
|
|
|
import com.example.fms.common.utils.Response;
|
|
|
import com.example.fms.domain.SystemFile;
|
|
|
import com.example.fms.service.FileMangerService;
|
|
|
+import com.example.fms.service.ReadPDF2Service;
|
|
|
+import com.example.fms.service.ReadPDFService;
|
|
|
import com.example.fms.service.SystemFileService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
@@ -18,7 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
-import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -33,12 +35,31 @@ import java.util.List;
|
|
|
public class FileMangerController {
|
|
|
private final FileMangerService fileManagerService;
|
|
|
private final SystemFileService systemFileService;
|
|
|
+ private final ReadPDFService readPDFService;
|
|
|
+ private final ReadPDF2Service readPDF2Service;
|
|
|
|
|
|
- @PostMapping("/uploadSystemFile")
|
|
|
+// @PostMapping("/uploadSystemFile")
|
|
|
+// @Operation(summary = "上传文件")
|
|
|
+// public String upload(@RequestBody List<MultipartFile> files, Integer sourceId) {
|
|
|
+// List<Integer> insertIds = fileManagerService.add(files, sourceId);
|
|
|
+// return Response.success(insertIds);
|
|
|
+// }
|
|
|
+
|
|
|
+ @PostMapping("/uploadFile")
|
|
|
@Operation(summary = "上传文件")
|
|
|
- public String upload(@RequestBody List<MultipartFile> files, Integer sourceId) {
|
|
|
- List<Integer> insertIds = fileManagerService.add(files, sourceId);
|
|
|
- return Response.success(insertIds);
|
|
|
+ public String uploadFile(@RequestBody List<MultipartFile> files, Integer sourceId) throws IOException {
|
|
|
+ if(files != null && files.size() != 0){
|
|
|
+ List<Integer> insertIds = fileManagerService.uploadFile(files, sourceId);
|
|
|
+ if(insertIds != null && insertIds.size() != 0){
|
|
|
+ return Response.success("上传文件成功,文件信息id为" + insertIds);
|
|
|
+ } else {
|
|
|
+ return Response.error("文件信息入表失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return Response.error("上传文件不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@GetMapping("/downloadSystemFile")
|
|
@@ -68,4 +89,11 @@ public class FileMangerController {
|
|
|
fileManagerService.delete(fMSDeleteFileDTO.getIds(), fMSDeleteFileDTO.getType());
|
|
|
return Response.success("删除系统文件成功");
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("/PDF")
|
|
|
+ @Operation(summary = "pdf")
|
|
|
+ public String pdf(String fileName) {
|
|
|
+ readPDF2Service.read(fileName);
|
|
|
+ return Response.success("导出图片");
|
|
|
+ }
|
|
|
}
|