From 040512413ebe1fcb2307e3a35907adb1ef6d2c93 Mon Sep 17 00:00:00 2001 From: JilingLee <18850011309@139.com> Date: Thu, 21 Sep 2023 17:35:33 +0800 Subject: [PATCH] =?UTF-8?q?ofd=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/invoices/InvoicesController.java | 13 +++++++++++-- .../module/infra/service/file/FileServiceImpl.java | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java index 0f547efb..25518037 100644 --- a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/invoices/InvoicesController.java @@ -164,7 +164,12 @@ public class InvoicesController { }else { invoicesDO.setDuplicateMark(Byte.valueOf(AccountingStatusEnum.UN_DUPLICATE_INVOICE.getValue())); } - String url = getUrl(multipartFile); + String url=""; + if (fileExtension.equalsIgnoreCase("ofd")) { + url = getUrl(multipartFile, UUID.randomUUID()+".ofd", "ofd"); + }else { + url = getUrl(multipartFile, "other", "other"); + } invoicesDO.setFileUrl(url); invoicesService.createInvoices(invoicesDO); return success(invoicesDO); @@ -190,8 +195,12 @@ public class InvoicesController { * @param file * @return */ - private String getUrl(MultipartFile file) throws Exception{ + private String getUrl(MultipartFile file,String name, String path) throws Exception{ String url=""; + if (path.equals("ofd")){ + url = fileService.createFile(name, path, IoUtil.readBytes(file.getInputStream())); + return url; + } url = fileService.createFile(null, null, IoUtil.readBytes(file.getInputStream())); return url; } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java index 0732765d..199c64a9 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java @@ -52,7 +52,12 @@ public class FileServiceImpl implements FileService { // 上传到文件存储器 FileClient client = fileConfigService.getMasterFileClient(); Assert.notNull(client, "客户端(master) 不能为空"); - String url = client.upload(content, path, type); + String url=""; + if (path.equals("ofd")) { + url = client.upload(content, name, "application/ofd"); + }else { + url = client.upload(content, path, type); + } // 保存到数据库 FileDO file = new FileDO(); @@ -60,7 +65,12 @@ public class FileServiceImpl implements FileService { file.setName(name); file.setPath(path); file.setUrl(url); - file.setType(type); + if (path.equals("ofd")) { + file.setType("application/ofd"); + }else { + file.setType(type); + } + file.setSize(content.length); fileMapper.insert(file); return url;