From 62a304eb5c68fc7f54a9bc247e76223cc2c7f243 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Wed, 14 Dec 2022 11:05:30 +0800
Subject: [PATCH] fix
---
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java
index b0022d6..df4c3b5 100644
--- a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java
+++ b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java
@@ -31,6 +31,7 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -89,6 +90,7 @@
return;
}
+ FileUtil.touch(new File(staticPath + "/empty.txt"));
for (File templateFile : files) {
if (!templateFile.isFile()) {
FileUtil.move(templateFile, new File(staticPath), true);
@@ -243,4 +245,18 @@
return Result.ok("保存成功");
}
+ @Override
+ public Result downloadTemplate() {
+ Long companyId = LoginUserUtil.getCompanyId();
+ CompanyEntity company = this.companyMapper.selectById(companyId);
+
+ String templatePath = FileUtils.path(cmsProperties.getTemplatePath(), company.getCode());
+ String staticPath = FileUtils.path(cmsProperties.getStaticPath(), company.getCode());
+ String downloadPath = FileUtils.path(cmsProperties.getDownloadPath(), company.getCode());
+
+ String fileName = "template.zip";
+ ZipUtil.zip(FileUtil.file(downloadPath + "/template.zip"), true, FileUtil.file(templatePath), FileUtil.file(staticPath));
+ String url = cmsProperties.getStaticUrl() + "download/" + company.getCode();
+ return Result.ok("success", url +"/" + fileName);
+ }
}
--
Gitblit v1.9.1