From 95ef76d6440a5363c0b7981b1333f82f9345322d Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Thu, 07 Jul 2022 15:15:56 +0800 Subject: [PATCH] fix template upload --- src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java | 13 +++++-------- 1 files changed, 5 insertions(+), 8 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 a4a194d..58c80e2 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 @@ -45,14 +45,14 @@ public class CmsTemplateServiceImpl extends ServiceImpl<CmsTemplateMapper, CmsTemplateEntity> implements ICmsTemplateService { @Autowired - private TemplateConfiguration cfg; + private CmsProperties properties; private List<String> fileSuffix = Arrays.asList(".zip", ".html"); @Override public void updateTemplate(MultipartFile upload) { - String templatePath = cfg.templatePath; - String staticPath = cfg.staticPath; + String templatePath = properties.getTemplatePath(); + String staticPath = properties.getStaticPath(); String filename = upload.getOriginalFilename(); String suffix = filename.substring(filename.lastIndexOf(".")); @@ -78,6 +78,7 @@ for (File templateFile : files) { if (!templateFile.isFile()) { + FileUtil.move(templateFile, new File(FileUtils.path(staticPath, templateFile.getName())), true); continue; } @@ -86,7 +87,7 @@ } String name = templateFile.getName(); - if (!name.endsWith(".list.html") && !name.endsWith(".article.html") && !name.endsWith(".index.html")) { + if (!name.endsWith(".list.html") && !name.endsWith(".article.html") && !name.endsWith("index.html")) { continue; } @@ -167,10 +168,6 @@ CmsTemplateEntity cmsTemplateEntity = this.baseMapper.selectById(id); String baseUrl = cmsProperties.getBaseUrl(); String templatePath = cmsProperties.getTemplatePath(); - File uploadDir = new File(templatePath); - if (!uploadDir.isDirectory()) { - uploadDir.mkdir(); - } String htmlUrl = baseUrl + templatePath; String pathName = htmlUrl + "\\" + cmsTemplateEntity.getPath(); -- Gitblit v1.9.1