Skip to content

Commit 45e10b4

Browse files
authored
Merge pull request OtterMind#734 from Zhuoyuan1/dev
Bug
2 parents 9b0cf9d + 2f40ba6 commit 45e10b4

6 files changed

Lines changed: 8 additions & 69 deletions

File tree

chat2db-server/chat2db-server-domain/chat2db-server-domain-core/src/main/java/ai/chat2db/server/domain/core/impl/TableServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public PageResult<Table> pageQuery(TablePageQueryParam param, TableSelector sele
206206
tables.add(t);
207207
}
208208
}
209+
tables = pinTable(tables, param);
209210
return PageResult.of(tables, total, param);
210211
}
211212

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/doc/constant/CommonConstant.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package ai.chat2db.server.web.api.controller.rdb.doc.constant;
22

3-
import lombok.extern.java.Log;
4-
53
/**
64
* CommonConstant
75
*
86
* @author lzy
97
**/
10-
@Log
118
public final class CommonConstant {
129
/**
1310
* 表head

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/doc/export/ExportHtmlService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import java.io.BufferedWriter;
1616
import java.io.ByteArrayOutputStream;
17-
import java.io.FileInputStream;
17+
import java.io.InputStream;
1818
import java.io.OutputStream;
1919
import java.io.OutputStreamWriter;
2020
import java.nio.charset.StandardCharsets;
@@ -86,8 +86,7 @@ public void export(OutputStream outputStream, ExportOptions exportOptions) {
8686
}
8787
catalogue.append("</li>");
8888

89-
String filePath = GlobalDict.templateDir + GlobalDict.TEMPLATE_FILE.get(0);
90-
try (FileInputStream inputStream = new FileInputStream(filePath);
89+
try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("template/" + GlobalDict.TEMPLATE_FILE.get(0));
9190
ByteArrayOutputStream result = new ByteArrayOutputStream()) {
9291
byte[] buffer = new byte[1024];
9392
int length;

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/doc/export/ExportWordSuperService.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import com.deepoove.poi.data.Tables;
1717
import lombok.SneakyThrows;
1818

19-
import java.io.File;
19+
import java.io.InputStream;
2020
import java.io.OutputStream;
2121
import java.util.ArrayList;
2222
import java.util.Arrays;
@@ -45,9 +45,8 @@ public ExportWordSuperService() {
4545
@Override
4646
public void export(OutputStream outputStream, ExportOptions exportOptions) {
4747
boolean isExportIndex = exportOptions.getIsExportIndex();
48-
String filePath = GlobalDict.templateDir + GlobalDict.TEMPLATE_FILE.get(1);
49-
String subFile = GlobalDict.templateDir + GlobalDict.TEMPLATE_FILE.get(2);
50-
File importWordFile = new File(filePath);
48+
InputStream filePath = this.getClass().getClassLoader().getResourceAsStream("template/" + GlobalDict.TEMPLATE_FILE.get(1));
49+
InputStream subFile = this.getClass().getClassLoader().getResourceAsStream("template/" + GlobalDict.TEMPLATE_FILE.get(2));
5150
Map<String, List<Map.Entry<String, List<TableParameter>>>> allMap = listMap.entrySet()
5251
.stream().collect(Collectors.groupingBy(v -> v.getKey().split("---")[0]));
5352
List<Map<String, Object>> list = new ArrayList<>();
@@ -86,9 +85,9 @@ public void export(OutputStream outputStream, ExportOptions exportOptions) {
8685
list.add(tableData);
8786
}
8887
}
89-
myDataMap.put("mydata", Includes.ofLocal(subFile).setRenderModel(list).create());
88+
myDataMap.put("mydata", Includes.ofStream(subFile).setRenderModel(list).create());
9089
/*根据模板生成文档*/
91-
XWPFTemplate template = XWPFTemplate.compile(importWordFile).render(myDataMap);
90+
XWPFTemplate template = XWPFTemplate.compile(filePath).render(myDataMap);
9291
AddToTopic.generateTOC(template.getXWPFDocument(), outputStream);
9392
}
9493

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/factory/CopyTemplate.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/factory/ExportServiceFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public class ExportServiceFactory {
2828
REPORT_POOL.put(ExportTypeEnum.MARKDOWN.name(), ExportMarkdownService.class);
2929
REPORT_POOL.put(ExportTypeEnum.HTML.name(), ExportHtmlService.class);
3030
REPORT_POOL.put(ExportTypeEnum.PDF.name(), ExportPdfService.class);
31-
CopyTemplate.copyTemplateFile();
3231
}
3332

3433
/**

0 commit comments

Comments
 (0)