2
0

feat: 下载发票pdf

This commit is contained in:
caiyuchao
2025-06-16 19:14:31 +08:00
parent b70ac9d5cc
commit 3dfee8e360
14 changed files with 98 additions and 17 deletions

View File

@@ -38,6 +38,7 @@ public class SysFileController {
sysFile.setName(FileUtils.getName(urlResult.getGatewayUrl()));
sysFile.setUrl(urlResult.getUrl());
sysFile.setLocalUrl(urlResult.getLocalUrl());
sysFile.setFilePath(urlResult.getFilePath());
sysFile.setGatewayUrl(urlResult.getGatewayUrl());
return R.ok(sysFile);
} catch (Exception e) {

View File

@@ -1,15 +1,16 @@
package org.wfc.file.service;
import java.io.InputStream;
import com.alibaba.nacos.common.utils.IoUtils;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import org.wfc.common.core.utils.file.FileTypeUtils;
import java.io.InputStream;
/**
* FastDFS 文件存储
*
@@ -42,6 +43,6 @@ public class FastDfsSysFileServiceImpl implements ISysFileService
FileTypeUtils.getExtension(file), null);
IoUtils.closeQuietly(inputStream);
String fileUrl = domain + "/" + storePath.getFullPath();
return new LocalSysFileServiceImpl.FileUploadResult(fileUrl, fileUrl, fileUrl);
return new LocalSysFileServiceImpl.FileUploadResult(fileUrl, fileUrl, fileUrl, fileUrl);
}
}

View File

@@ -50,20 +50,23 @@ public class LocalSysFileServiceImpl implements ISysFileService
public FileUploadResult uploadFile(MultipartFile file) throws Exception {
String name = FileUploadUtils.upload(localFilePath, file);
String url = localFilePrefix + name;
String filePath = localFilePath + name;
String localUrl = domain + localFilePrefix + name;
String gatewayUrl = gateway + pathPrefix + localFilePrefix + name;
return new FileUploadResult(url, localUrl, gatewayUrl);
return new FileUploadResult(url, localUrl, gatewayUrl, filePath);
}
public static class FileUploadResult {
private final String url;
private final String localUrl;
private final String gatewayUrl;
private final String filePath;
public FileUploadResult(String url, String localUrl, String gatewayUrl) {
public FileUploadResult(String url, String localUrl, String gatewayUrl, String filePath) {
this.url = url;
this.localUrl = localUrl;
this.gatewayUrl = gatewayUrl;
this.filePath = filePath;
}
public String getUrl() {
@@ -77,5 +80,9 @@ public class LocalSysFileServiceImpl implements ISysFileService
public String getGatewayUrl() {
return gatewayUrl;
}
public String getFilePath() {
return filePath;
}
}
}

View File

@@ -1,14 +1,15 @@
package org.wfc.file.service;
import java.io.InputStream;
import com.alibaba.nacos.common.utils.IoUtils;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.nacos.common.utils.IoUtils;
import org.wfc.file.config.MinioConfig;
import org.wfc.file.utils.FileUploadUtils;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import java.io.InputStream;
/**
* Minio 文件存储
@@ -45,6 +46,6 @@ public class MinioSysFileServiceImpl implements ISysFileService
client.putObject(args);
IoUtils.closeQuietly(inputStream);
String fileUrl = minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
return new LocalSysFileServiceImpl.FileUploadResult(fileUrl, fileUrl, fileUrl);
return new LocalSysFileServiceImpl.FileUploadResult(fileUrl, fileUrl, fileUrl, fileUrl);
}
}