| @@ -14,7 +14,8 @@ import com.xueyi.file.config.MinioConfig; | |||
| import com.xueyi.file.service.ISysFileService; | |||
| import com.xueyi.file.service.MinioSysFileServiceImpl; | |||
| import com.xueyi.file.utils.PdfToImageUtil; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.DeleteMapping; | |||
| import org.springframework.web.bind.annotation.PathVariable; | |||
| @@ -34,10 +35,11 @@ import java.util.List; | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Slf4j | |||
| @RestController | |||
| public class SysFileController { | |||
| private static final Logger log = LoggerFactory.getLogger(SysFileController.class); | |||
| @Autowired | |||
| private ISysFileService sysFileService; | |||
| @@ -56,7 +58,7 @@ public class SysFileController { | |||
| @PostMapping("/inner/upload") | |||
| public R<SysFile> uploadInner(MultipartFile file) { | |||
| try { | |||
| System.out.println("文件上传开始:" + file.getName()); | |||
| log.info("文件上传开始:" + file.getName()); | |||
| // 上传并返回访问地址 | |||
| String url = sysFileService.uploadFile(file); | |||
| SysFile sysFile = new SysFile(); | |||
| @@ -76,7 +78,7 @@ public class SysFileController { | |||
| @PostMapping("/inner/upload-temp") | |||
| public R<SysFile> uploadTempInner(MultipartFile file) { | |||
| try { | |||
| System.out.println("文件上传开始:" + file.getName()); | |||
| log.info("文件上传开始:" + file.getName()); | |||
| // 上传并返回访问地址 | |||
| String url = sysFileService.uploadTempFile(file); | |||
| SysFile sysFile = new SysFile(); | |||
| @@ -100,18 +102,18 @@ public class SysFileController { | |||
| public R<List<SysFile>> uploadPdfInner(MultipartFile file) { | |||
| try { | |||
| Long startTs = System.currentTimeMillis(); | |||
| System.out.println("文件上传开始:" + file.getName()+"; start ts:"+startTs); | |||
| log.info("文件上传开始:" + file.getName()+"; start ts:"+startTs); | |||
| // pdf文件转成图片集合 | |||
| List<File> fileList = PdfToImageUtil.pdfToTransformationList(file); | |||
| Long pdfTs = System.currentTimeMillis(); | |||
| System.out.println("PDF转换图片完成, 用时:"+(pdfTs-startTs)+"ms"); | |||
| log.info("PDF转换图片完成, 用时:"+(pdfTs-startTs)+"ms"); | |||
| List<SysFile> results = new ArrayList<>(); | |||
| int num = 1; | |||
| System.out.println("开始上传图片。。。"); | |||
| log.info("开始上传图片。。。"); | |||
| // 循环上传并返回日志集合 | |||
| for (File f : fileList) { | |||
| //将file的文件名重命名为file文件名+两位数的num | |||
| System.out.println("上传第"+num+"张图片开始。。。"); | |||
| log.info("上传第"+num+"张图片开始。。。"); | |||
| String fileName = f.getName(); | |||
| String suffix = fileName.substring(fileName.lastIndexOf(".")); | |||
| String name = fileName.substring(0, fileName.lastIndexOf(".")); | |||
| @@ -125,10 +127,10 @@ public class SysFileController { | |||
| sysFile.setNick(sysFile.getName()); | |||
| remoteFileManageService.saveFileLog(sysFile, SecurityConstants.INNER); | |||
| results.add(sysFile); | |||
| System.out.println("上传第"+(num-1)+"张图片完成。。。"); | |||
| log.info("上传第"+(num-1)+"张图片完成。。。"); | |||
| }; | |||
| long endTs = System.currentTimeMillis(); | |||
| System.out.println("上传图片结束。。。,用时:"+(endTs-pdfTs)+"ms"); | |||
| log.info("上传图片结束。。。,用时:"+(endTs-pdfTs)+"ms"); | |||
| return R.ok(results); | |||
| } catch (Exception e) { | |||