mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-30 19:22:58 +08:00
fix template copy error
This commit is contained in:
@ -1,26 +0,0 @@
|
||||
package ai.chat2db.server.start.listener;
|
||||
|
||||
import ai.chat2db.server.start.config.util.CopyTemplate;
|
||||
import ai.chat2db.server.web.api.controller.rdb.doc.event.TemplateEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* TemplateListener
|
||||
*
|
||||
* @author lzy
|
||||
**/
|
||||
@Component
|
||||
public class TemplateListener {
|
||||
|
||||
@Autowired
|
||||
private CopyTemplate copyTemplate;
|
||||
|
||||
@EventListener(classes = TemplateEvent.class)
|
||||
public void copyTemplate() {
|
||||
//复制模板
|
||||
copyTemplate.copyTemplateFile();
|
||||
}
|
||||
|
||||
}
|
@ -50,8 +50,6 @@ public class RdbDocController {
|
||||
@Autowired
|
||||
private RdbWebConverter rdbWebConverter;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
* export data
|
||||
@ -61,7 +59,6 @@ public class RdbDocController {
|
||||
@PostMapping("/export")
|
||||
public void export(@Valid @RequestBody DataExportRequest request, HttpServletResponse response) throws Exception {
|
||||
//复制模板
|
||||
applicationContext.publishEvent(new TemplateEvent("copy"));
|
||||
ExportTypeEnum exportType = EasyEnumUtils.getEnum(ExportTypeEnum.class, request.getExportType());
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String fileName = URLEncoder.encode(
|
||||
|
@ -1,8 +1,7 @@
|
||||
package ai.chat2db.server.start.config.util;
|
||||
package ai.chat2db.server.web.api.controller.rdb.factory;
|
||||
|
||||
import ai.chat2db.server.tools.common.util.ConfigUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -15,7 +14,6 @@ import java.util.List;
|
||||
*
|
||||
* @author lzy
|
||||
**/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CopyTemplate {
|
||||
/**
|
||||
@ -23,7 +21,7 @@ public class CopyTemplate {
|
||||
**/
|
||||
private static final List<String> TEMPLATE_FILE = Arrays.asList("template.html", "template_diy.docx", "sub_template_diy.docx");
|
||||
|
||||
public void copyTemplateFile() {
|
||||
public static void copyTemplateFile() {
|
||||
String templateDir = ConfigUtils.CONFIG_BASE_PATH + File.separator + "template";
|
||||
File file = new File(templateDir);
|
||||
if (!file.exists()) {
|
||||
@ -34,7 +32,7 @@ public class CopyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveFile(String dir, String path, boolean isOverride) {
|
||||
private static void saveFile(String dir, String path, boolean isOverride) {
|
||||
if (!isOverride) {
|
||||
File file = new File(dir + File.separator + path);
|
||||
if (file.exists()) {
|
@ -19,12 +19,16 @@ public class ExportServiceFactory {
|
||||
*/
|
||||
private static final Map<String, Class<?>> REPORT_POOL = new ConcurrentHashMap<>(8);
|
||||
|
||||
|
||||
|
||||
|
||||
static {
|
||||
REPORT_POOL.put(ExportTypeEnum.EXCEL.name(), ExportExcelService.class);
|
||||
REPORT_POOL.put(ExportTypeEnum.WORD.name(), ExportWordSuperService.class);
|
||||
REPORT_POOL.put(ExportTypeEnum.MARKDOWN.name(), ExportMarkdownService.class);
|
||||
REPORT_POOL.put(ExportTypeEnum.HTML.name(), ExportHtmlService.class);
|
||||
REPORT_POOL.put(ExportTypeEnum.PDF.name(), ExportPdfService.class);
|
||||
CopyTemplate.copyTemplateFile();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user