Commit 50773f20 by gonglei

加入框架代码

1 parent c03823ff
......@@ -45,8 +45,6 @@ dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
testImplementation('org.springframework.boot:spring-boot-starter-test')
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'com.aspose:aspose-words:25.2:jdk17'
implementation 'com.aspose:aspose-cells:24.2'
// 排除 slf4j-simple,如果被其他库引入
configurations.all {
exclude group: 'org.slf4j', module: 'slf4j-simple'
......
......@@ -43,8 +43,6 @@ dependencies {
implementation 'io.github.swalikh:wework-wehook-starter:1.0.0'
runtimeOnly 'com.mysql:mysql-connector-j'
compileOnly("org.projectlombok:lombok")
implementation 'com.aspose:aspose-words:25.2:jdk17'
implementation 'com.aspose:aspose-cells:24.2'
// implementation 'redis.clients:jedis:3.3.0'
// implementation 'com.github.jedis-lock:jedis-lock:1.0.0'
......
......@@ -68,9 +68,9 @@ spring:
data:
redis:
database: 6
host: localhost
port: 6379
password:
host: 120.237.107.125
port: 16379
password: Ml1234..
# 连接超时时间 单位 ms(毫秒)
timeout: 3000ms
jedis:
......
......@@ -41,8 +41,6 @@ dependencies {
implementation 'org.apache.poi:poi:5.4.0'
implementation 'org.apache.poi:poi-ooxml:5.4.0'
implementation 'org.apache.poi:poi-scratchpad:5.4.0'
compileOnly 'com.aspose:aspose-words:25.2:jdk17'
compileOnly 'com.aspose:aspose-cells:24.2'
// 滑动验证码
implementation 'cloud.tianai.captcha:tianai-captcha-springboot-starter:1.4.1'
compileOnly 'org.projectlombok:lombok'
......
package org.summerframework.storage.platform;
import com.aspose.cells.*;
import com.aspose.words.*;
import com.aspose.words.ImageSaveOptions;
import com.aspose.words.ImageType;
import com.aspose.words.SaveFormat;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -189,26 +185,6 @@ public abstract class AbstractStorageService implements StorageService {
}
protected void thumbWord(String sourceFilePath, String targetFilePath) throws Exception {
// 加载 Word 文档
Document doc = new Document(sourceFilePath);
// 渲染第一页为图片
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.PNG);
// 从第0页开始 仅渲染一页
options.setPageSet(new PageSet(0, 1));
// 分辨率
options.setResolution(150);
String outputImagePath = sourceFilePath.substring(0, sourceFilePath.lastIndexOf(".")) + ".png";
doc.save(outputImagePath, options);
// 生成缩略图(可选)
File outputImageFile = new File(outputImagePath);
BufferedImage image = ImageIO.read(outputImageFile);
BufferedImage thumbnail = resizeImage(image, thumbnailsWidth, thumbnailsHeight); // 你可以指定缩略图大小
ImageIO.write(thumbnail, "png", new File(targetFilePath));
outputImageFile.delete();
}
protected void thumbPdf(String sourceFilePath, String targetFilePath) throws IOException {
// 加载 PDF 文件
FileInputStream file = new FileInputStream(sourceFilePath);
......@@ -227,30 +203,6 @@ public abstract class AbstractStorageService implements StorageService {
document.close();
}
protected void thumbExcel(String sourceFilePath, String targetFilePath) throws Exception {
// 加载 Excel 文件
Workbook workbook = new Workbook(sourceFilePath);
// 获取第一个工作表
Worksheet sheet = workbook.getWorksheets().get(0);
// 渲染选项
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageType(ImageType.PNG);
options.setOnePagePerSheet(true); // 将整张表渲染为一页
options.setOnlyArea(false); // 如果只想渲染有内容的区域,设置为 true
options.setPrintingPage(PrintingPageType.DEFAULT);
// 渲染器
SheetRender render = new SheetRender(sheet, options);
String outputImagePath = sourceFilePath.substring(0, sourceFilePath.lastIndexOf(".")) + ".png";
// 渲染第一页(通常每个 sheet 只有一页)
render.toImage(0, outputImagePath);
// 生成缩略图(可选)
File outputImageFile = new File(outputImagePath);
BufferedImage image = ImageIO.read(outputImageFile);
BufferedImage thumbnail = resizeImage(image, thumbnailsWidth, thumbnailsHeight); // 你可以指定缩略图大小
ImageIO.write(thumbnail, "png", new File(targetFilePath));
outputImageFile.delete();
}
protected void thumbPpt(String sourceFilePath, String targetFilePath) throws IOException {
// 1. 加载 PPTX 文件
......
......@@ -202,7 +202,7 @@ public class LocalFileService extends AbstractStorageService implements StorageS
@Override
public void removeFileInfo(@Nullable FileInfo fileInfo) {
if(Objects.nonNull(fileInfo)){
if (Objects.nonNull(fileInfo)) {
removeFile(fileInfo.getFilePath());
}
}
......@@ -318,9 +318,7 @@ public class LocalFileService extends AbstractStorageService implements StorageS
thumbPath = thumbDir + this.getRandomFileName(filename);
Thumbnails.of(sourceFile).size(thumbnailsWidth, thumbnailsHeight).crop(Positions.CENTER).toFile(absoluteDir + thumbPath);
} else if ("doc".equals(suffix) || "docx".equals(suffix)) {
thumbWord(sourceFile.getAbsolutePath(), absoluteDir + thumbPath);
} else if ("xls".equals(suffix) || "xlsx".equals(suffix)) {
thumbExcel(sourceFile.getAbsolutePath(), absoluteDir + thumbPath);
} else if ("ppt".equals(suffix) || "pptx".equals(suffix)) {
thumbPpt(sourceFile.getAbsolutePath(), absoluteDir + thumbPath);
} else if ("pdf".equals(suffix)) {
......
......@@ -42,8 +42,6 @@ dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
testImplementation('org.springframework.boot:spring-boot-starter-test')
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'com.aspose:aspose-words:25.2:jdk17'
implementation 'com.aspose:aspose-cells:24.2'
// 排除 slf4j-simple,如果被其他库引入
configurations.all {
exclude group: 'org.slf4j', module: 'slf4j-simple'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!