| | |
| | | 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; |
| | |
| | | return; |
| | | } |
| | | |
| | | FileUtil.touch(new File(staticPath + "/empty.txt")); |
| | | for (File templateFile : files) { |
| | | if (!templateFile.isFile()) { |
| | | FileUtil.move(templateFile, new File(staticPath), true); |
| | |
| | | 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); |
| | | } |
| | | } |